Skip to content

Commit

Permalink
Better condition timing in AddonConditionWatcherTriggerTimeSecs (#9711)
Browse files Browse the repository at this point in the history
  • Loading branch information
oskirby committed Jul 3, 2024
1 parent 258193e commit bd5837b
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,15 @@ bool AddonConditionWatcherTriggerTimeSecs::conditionApplied() const {

bool AddonConditionWatcherTriggerTimeSecs::maybeStartTimer() {
QDateTime now = QDateTime::currentDateTime();
QDateTime installation = SettingsHolder::instance()->installationTime();
QDateTime expire =
SettingsHolder::instance()->installationTime().addSecs(m_triggerTimeSecs);

// Note: triggerTimeSecs is seconds!
CheckedInt<int> secs =
static_cast<int>(m_triggerTimeSecs - installation.secsTo(now));
if (secs.value() <= 0) {
if (expire <= now) {
return true;
}

m_timer.setSingleShot(true);
secs *= 1000;
m_timer.start(secs.isValid() ? secs.value()
: std::numeric_limits<int>::max());
m_timer.start(now.msecsTo(expire));

return false;
}

0 comments on commit bd5837b

Please sign in to comment.