UI: TaskInfo::secondsToRun: Fix delayed startup

This commit is contained in:
Nodir Temirkhodjaev 2024-10-19 14:43:04 +05:00
parent 48461bac2a
commit b13c0e9eae
2 changed files with 12 additions and 3 deletions

View File

@ -54,10 +54,18 @@ void TaskInfo::editFromVariant(const QVariant &v)
setIntervalHours(task.intervalHours());
}
qint64 TaskInfo::secondsToRun(const QDateTime &now, bool isFirstRun) const
qint64 TaskInfo::secondsToRun(const QDateTime &now, bool isFirstRun)
{
if (isFirstRun && runOnStartup()) {
return delayStartup() ? retrySeconds() : 0;
m_isFirstDelayRun = true;
if (delayStartup()) {
return retrySeconds();
}
}
if (m_isFirstDelayRun) {
m_isFirstDelayRun = false;
return 0;
}
const qint64 delaySecs = (m_failedCount > 0) ? retrySeconds() : (intervalHours() * 60 * 60);

View File

@ -78,7 +78,7 @@ public:
void editFromVariant(const QVariant &v);
qint64 secondsToRun(const QDateTime &now, bool isFirstRun) const;
qint64 secondsToRun(const QDateTime &now, bool isFirstRun);
virtual void initialize() { }
@ -108,6 +108,7 @@ private:
bool m_enabled : 1 = false;
bool m_runOnStartup : 1 = false;
bool m_delayStartup : 1 = false;
bool m_isFirstDelayRun : 1 = false; // transient
bool m_running : 1 = false;
bool m_aborted : 1 = false; // transient