summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/vcl/idle.hxx2
-rw-r--r--include/vcl/task.hxx13
-rw-r--r--include/vcl/timer.hxx8
-rw-r--r--vcl/source/app/idle.cxx7
-rw-r--r--vcl/source/app/scheduler.cxx5
-rw-r--r--vcl/source/app/timer.cxx7
6 files changed, 26 insertions, 16 deletions
diff --git a/include/vcl/idle.hxx b/include/vcl/idle.hxx
index 78fcaae817b9..9abafae440d8 100644
--- a/include/vcl/idle.hxx
+++ b/include/vcl/idle.hxx
@@ -46,7 +46,7 @@ protected:
public:
Idle( const char *pDebugName = nullptr );
- virtual void Start() override;
+ virtual void Start(bool bStartTimer = true) override;
};
/**
diff --git a/include/vcl/task.hxx b/include/vcl/task.hxx
index e95aa5bc460a..3785e37fba53 100644
--- a/include/vcl/task.hxx
+++ b/include/vcl/task.hxx
@@ -85,7 +85,18 @@ public:
// Call handler
virtual void Invoke() = 0;
- virtual void Start();
+ /**
+ * Schedules the task for execution
+ *
+ * If the timer is already active, it's reset!
+ * Check with Task::IsActive() to prevent reset.
+ *
+ * If you unset bStartTimer, the Task must call Task::StartTimer(...) to be correctly scheduled!
+ * Otherwise it might just be picked up when the Scheduler runs the next time.
+ *
+ * @param bStartTimer if false, don't schedule the Task by calling Task::StartTimer(0).
+ */
+ virtual void Start(bool bStartTimer = true);
void Stop();
bool IsActive() const { return mbActive; }
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index d9ad82ee5729..cd8733518093 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -58,13 +58,7 @@ public:
void SetTimeout( sal_uInt64 nTimeoutMs );
sal_uInt64 GetTimeout() const { return mnTimeout; }
- /**
- * Activates the timer task
- *
- * If the timer is already active, it's reset!
- * Check with Task::IsActive() to prevent reset.
- */
- virtual void Start() override;
+ virtual void Start(bool bStartTimer = true) override;
};
/// An auto-timer is a multi-shot timer re-emitting itself at
diff --git a/vcl/source/app/idle.cxx b/vcl/source/app/idle.cxx
index 26e1e5f22210..7e5756537164 100644
--- a/vcl/source/app/idle.cxx
+++ b/vcl/source/app/idle.cxx
@@ -31,9 +31,9 @@ Idle::Idle( const char *pDebugName )
{
}
-void Idle::Start()
+void Idle::Start(const bool bStartTimer)
{
- Task::Start();
+ Task::Start(false);
sal_uInt64 nPeriod = Scheduler::ImmediateTimeoutMs;
if (Scheduler::GetDeterministicMode())
@@ -49,7 +49,8 @@ void Idle::Start()
}
}
- Task::StartTimer(nPeriod);
+ if (bStartTimer)
+ Task::StartTimer(nPeriod);
}
sal_uInt64 Idle::UpdateMinPeriod( sal_uInt64 /* nTimeNow */ ) const
diff --git a/vcl/source/app/scheduler.cxx b/vcl/source/app/scheduler.cxx
index 735792cfc3e2..c6f3f6b737d4 100644
--- a/vcl/source/app/scheduler.cxx
+++ b/vcl/source/app/scheduler.cxx
@@ -542,7 +542,7 @@ void Task::SetDeletionFlags()
mbActive = false;
}
-void Task::Start()
+void Task::Start(const bool bStartTimer)
{
ImplSVData *const pSVData = ImplGetSVData();
ImplSchedulerContext &rSchedCtx = pSVData->maSchedCtx;
@@ -582,6 +582,9 @@ void Task::Start()
<< " " << mpSchedulerData << " restarted " << *this );
mpSchedulerData->mnUpdateTime = tools::Time::GetSystemTicks();
+
+ if (bStartTimer)
+ Task::StartTimer(0);
}
void Task::Stop()
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 75a97d867195..183cd41a4e2b 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -80,10 +80,11 @@ void Timer::Invoke( Timer *arg )
maInvokeHandler.Call( arg );
}
-void Timer::Start()
+void Timer::Start(const bool bStartTimer)
{
- Task::Start();
- Task::StartTimer( mnTimeout );
+ Task::Start(false);
+ if (bStartTimer)
+ Task::StartTimer(mnTimeout);
}
void Timer::SetTimeout( sal_uInt64 nNewTimeout )