[Libreoffice-commits] core.git: include/vcl vcl/source
Michael Meeks
michael.meeks at collabora.com
Wed Mar 11 05:55:17 PDT 2015
include/vcl/timer.hxx | 3 +++
vcl/source/app/timer.cxx | 27 ++++++++++++++++++++-------
2 files changed, 23 insertions(+), 7 deletions(-)
New commits:
commit 22cd725fd66f8299f23367a2eac7aaa403ed74aa
Author: Michael Meeks <michael.meeks at collabora.com>
Date: Wed Mar 11 12:58:42 2015 +0000
vcl timers: avoid crash with vcldemo.
The system timer needs earlier and/or more consistent initialization.
Change-Id: I148d98537cc055a091181bd36a654ae35f665aaf
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx
index d671919..c5849a2 100644
--- a/include/vcl/timer.hxx
+++ b/include/vcl/timer.hxx
@@ -34,6 +34,9 @@ protected:
virtual bool ReadyForSchedule( bool bTimer ) SAL_OVERRIDE;
virtual sal_uInt64 UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime ) SAL_OVERRIDE;
+private:
+ void InitSystemTimer();
+
public:
Timer();
Timer( const Timer& rTimer );
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index 6c1724e..565751f 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -81,11 +81,27 @@ sal_uInt64 Timer::UpdateMinPeriod( sal_uInt64 nMinPeriod, sal_uInt64 nTime )
return nMinPeriod;
}
+/**
+ * Initialize the platform specific timer on which all the
+ * platform independent timers are built
+ */
+void Timer::InitSystemTimer()
+{
+ ImplSVData* pSVData = ImplGetSVData();
+ if( ! pSVData->mpSalTimer )
+ {
+ pSVData->mnTimerPeriod = MAX_TIMER_PERIOD;
+ pSVData->mpSalTimer = pSVData->mpDefInst->CreateSalTimer();
+ pSVData->mpSalTimer->SetCallback( CallbackTaskScheduling );
+ }
+}
+
Timer::Timer() : Scheduler()
{
mnTimeout = 1;
mbAuto = false;
mePriority = SchedulerPriority::HIGHEST;
+ InitSystemTimer();
}
Timer::Timer( const Timer& rTimer ) : Scheduler(rTimer)
@@ -93,6 +109,7 @@ Timer::Timer( const Timer& rTimer ) : Scheduler(rTimer)
mnTimeout = rTimer.mnTimeout;
mbAuto = rTimer.mbAuto;
maTimeoutHdl = rTimer.maTimeoutHdl;
+ InitSystemTimer();
}
void Timer::Invoke()
@@ -103,13 +120,9 @@ void Timer::Invoke()
void Timer::Start()
{
Scheduler::Start();
- ImplSVData* pSVData = ImplGetSVData();
- if( ! pSVData->mpSalTimer )
- {
- pSVData->mnTimerPeriod = MAX_TIMER_PERIOD;
- pSVData->mpSalTimer = pSVData->mpDefInst->CreateSalTimer();
- pSVData->mpSalTimer->SetCallback( CallbackTaskScheduling );
- }
+
+ ImplSVData* pSVData = ImplGetSVData();
+ assert( pSVData->mpSalTimer != NULL );
if ( mnTimeout < pSVData->mnTimerPeriod )
Timer::ImplStartTimer( pSVData, mnTimeout );
}
More information about the Libreoffice-commits
mailing list