summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2014-09-23 21:27:46 +0100
committerMichael Meeks <michael.meeks@collabora.com>2014-09-23 21:30:47 +0100
commitda21f7da44dc577a08ea3bc210083dc8decf18bc (patch)
treebd7ca8196696b8aaa89fa86cae2dccda78524db2
parent211b3192f05c4120fa2dd0e23988e74bdd310830 (diff)
fdo#84000 - unwind recursive timer issues.
Seemingly timers were not being issued or re-queued. Handle recursion issues in the main thread, not in the timer thread. Change-Id: I4f49341115bb7c7b1613e61f77a467154818a8aa
-rw-r--r--vcl/source/app/timer.cxx1
-rw-r--r--vcl/win/source/app/saltimer.cxx40
2 files changed, 15 insertions, 26 deletions
diff --git a/vcl/source/app/timer.cxx b/vcl/source/app/timer.cxx
index f83f55ceb14e..1f9870b2b436 100644
--- a/vcl/source/app/timer.cxx
+++ b/vcl/source/app/timer.cxx
@@ -70,6 +70,7 @@ static void ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS )
if ( !nMS )
nMS = 1;
+ // Assume underlying timers are recurring timers, if same period - just wait.
if ( nMS != pSVData->mnTimerPeriod )
{
pSVData->mnTimerPeriod = nMS;
diff --git a/vcl/win/source/app/saltimer.cxx b/vcl/win/source/app/saltimer.cxx
index 779c6918647b..fdfa5c0500ac 100644
--- a/vcl/win/source/app/saltimer.cxx
+++ b/vcl/win/source/app/saltimer.cxx
@@ -54,11 +54,9 @@ void ImplSalStartTimer( sal_uLong nMS, bool bMutex )
if (nMS > MAX_SYSPERIOD)
nMS = MAX_SYSPERIOD;
- // change if it exists, create if not
- if (pSalData->mnTimerId)
- ChangeTimerQueueTimer(NULL, pSalData->mnTimerId, nMS, nMS);
- else
- CreateTimerQueueTimer(&pSalData->mnTimerId, NULL, SalTimerProc, NULL, nMS, nMS, WT_EXECUTEDEFAULT);
+ // can't change a one-shot timer if it has fired already (odd) so delete & re-create
+ ImplSalStopTimer(pSalData);
+ CreateTimerQueueTimer(&pSalData->mnTimerId, NULL, SalTimerProc, NULL, nMS, nMS, WT_EXECUTEDEFAULT);
pSalData->mnNextTimerTime = pSalData->mnLastEventTime + nMS;
}
@@ -111,15 +109,10 @@ void CALLBACK SalTimerProc(PVOID, BOOLEAN)
__try
{
#endif
+
SalData* pSalData = GetSalData();
- ImplSVData* pSVData = ImplGetSVData();
-
- // don't allow recursive calls (mbInTimerProc is set when the callback
- // is being processed)
- if (pSVData->mpSalTimer && !pSalData->mbInTimerProc)
- {
- ImplPostMessage(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_TIMER_CALLBACK, 0, 0);
- }
+ ImplPostMessage(pSalData->mpFirstInstance->mhComWnd, SAL_MSG_TIMER_CALLBACK, 0, 0);
+
#if defined ( __MINGW32__ ) && !defined ( _WIN64 )
}
han.Reset();
@@ -149,23 +142,18 @@ void EmitTimerCallback(bool bAllowRecursive)
// Try to acquire the mutex. If we don't get the mutex then we
// try this a short time later again.
- if (ImplSalYieldMutexTryToAcquire())
+ if (ImplSalYieldMutexTryToAcquire() &&
+ (pSVData->mpSalTimer && (!pSalData->mbInTimerProc || bAllowRecursive)))
{
- if (pSVData->mpSalTimer && (!pSalData->mbInTimerProc || bAllowRecursive))
- {
- pSalData->mbInTimerProc = true;
- pSVData->mpSalTimer->CallCallback();
- pSalData->mbInTimerProc = false;
- ImplSalYieldMutexRelease();
-
- // Run the timer in the correct time, if we start this
- // with a small timeout, because we don't get the mutex
- if (pSalData->mnTimerId && (pSalData->mnTimerMS != pSalData->mnTimerOrgMS))
- ImplSalStartTimer(pSalData->mnTimerOrgMS, false);
- }
+ pSalData->mbInTimerProc = true;
+ pSVData->mpSalTimer->CallCallback();
+ pSalData->mbInTimerProc = false;
+ ImplSalYieldMutexRelease();
}
else
+ {
ImplSalStartTimer(10, true);
+ }
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */