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 /vcl/source/app/timer.cxx | |
parent | 4e4d38faa41fb725bdff8bf4079418b5f1238d80 (diff) |
vcl timers: avoid crash with vcldemo.
The system timer needs earlier and/or more consistent initialization.
Change-Id: I148d98537cc055a091181bd36a654ae35f665aaf
Diffstat (limited to 'vcl/source/app/timer.cxx')
-rw-r--r-- | vcl/source/app/timer.cxx | 27 |
1 files changed, 20 insertions, 7 deletions
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 ); } |