diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2015-03-11 12:58:42 +0000 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2015-03-11 12:59:48 +0000 |
commit | 22cd725fd66f8299f23367a2eac7aaa403ed74aa (patch) | |
tree | 10f028ec6f4b35bab6386d52b6bba88c9d0d04ae | |
parent | 4e4d38faa41fb725bdff8bf4079418b5f1238d80 (diff) |
vcl timers: avoid crash with vcldemo.
The system timer needs earlier and/or more consistent initialization.
Change-Id: I148d98537cc055a091181bd36a654ae35f665aaf
-rw-r--r-- | include/vcl/timer.hxx | 3 | ||||
-rw-r--r-- | vcl/source/app/timer.cxx | 27 |
2 files changed, 23 insertions, 7 deletions
diff --git a/include/vcl/timer.hxx b/include/vcl/timer.hxx index d671919f5687..c5849a23cf8b 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 6c1724eb47ee..565751f0ea0d 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 ); } |