Kaydet (Commit) da21f7da authored tarafından Michael Meeks's avatar Michael Meeks

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
üst 211b3192
...@@ -70,6 +70,7 @@ static void ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS ) ...@@ -70,6 +70,7 @@ static void ImplStartTimer( ImplSVData* pSVData, sal_uLong nMS )
if ( !nMS ) if ( !nMS )
nMS = 1; nMS = 1;
// Assume underlying timers are recurring timers, if same period - just wait.
if ( nMS != pSVData->mnTimerPeriod ) if ( nMS != pSVData->mnTimerPeriod )
{ {
pSVData->mnTimerPeriod = nMS; pSVData->mnTimerPeriod = nMS;
......
...@@ -54,10 +54,8 @@ void ImplSalStartTimer( sal_uLong nMS, bool bMutex ) ...@@ -54,10 +54,8 @@ void ImplSalStartTimer( sal_uLong nMS, bool bMutex )
if (nMS > MAX_SYSPERIOD) if (nMS > MAX_SYSPERIOD)
nMS = MAX_SYSPERIOD; nMS = MAX_SYSPERIOD;
// change if it exists, create if not // can't change a one-shot timer if it has fired already (odd) so delete & re-create
if (pSalData->mnTimerId) ImplSalStopTimer(pSalData);
ChangeTimerQueueTimer(NULL, pSalData->mnTimerId, nMS, nMS);
else
CreateTimerQueueTimer(&pSalData->mnTimerId, NULL, SalTimerProc, NULL, nMS, nMS, WT_EXECUTEDEFAULT); CreateTimerQueueTimer(&pSalData->mnTimerId, NULL, SalTimerProc, NULL, nMS, nMS, WT_EXECUTEDEFAULT);
pSalData->mnNextTimerTime = pSalData->mnLastEventTime + nMS; pSalData->mnNextTimerTime = pSalData->mnLastEventTime + nMS;
...@@ -111,15 +109,10 @@ void CALLBACK SalTimerProc(PVOID, BOOLEAN) ...@@ -111,15 +109,10 @@ void CALLBACK SalTimerProc(PVOID, BOOLEAN)
__try __try
{ {
#endif #endif
SalData* pSalData = GetSalData();
ImplSVData* pSVData = ImplGetSVData();
// don't allow recursive calls (mbInTimerProc is set when the callback SalData* pSalData = GetSalData();
// 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 ) #if defined ( __MINGW32__ ) && !defined ( _WIN64 )
} }
han.Reset(); han.Reset();
...@@ -149,23 +142,18 @@ void EmitTimerCallback(bool bAllowRecursive) ...@@ -149,23 +142,18 @@ void EmitTimerCallback(bool bAllowRecursive)
// Try to acquire the mutex. If we don't get the mutex then we // Try to acquire the mutex. If we don't get the mutex then we
// try this a short time later again. // 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; pSalData->mbInTimerProc = true;
pSVData->mpSalTimer->CallCallback(); pSVData->mpSalTimer->CallCallback();
pSalData->mbInTimerProc = false; pSalData->mbInTimerProc = false;
ImplSalYieldMutexRelease(); 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);
}
} }
else else
{
ImplSalStartTimer(10, true); ImplSalStartTimer(10, true);
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment