tdf#119458 fix sw background Idle unblocking

We can't handle the correct state when blocking via a tasks
mbActive bool, as this also schedules the task and starts the
scheduler timer. So reintroduce a bool for the unblock state.

Change-Id: I40991d0160b058fae3803fab002dc036fc0b0339
Reviewed-on: https://gerrit.libreoffice.org/59692
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
Jan-Marek Glogowski
2018-08-28 13:13:12 +02:00
parent e82785887a
commit 771544544e
2 changed files with 18 additions and 4 deletions
+17 -4
View File
@@ -39,6 +39,7 @@ namespace sw
DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc ),
m_nIdleBlockCount( 0 ),
m_bStartOnUnblock( false ),
m_aDocIdle( i_rSwdoc )
{
m_aDocIdle.SetPriority(TaskPriority::LOWEST);
@@ -48,18 +49,26 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc ) : m_rDoc( i_rSwdoc
void DocumentTimerManager::StartIdling()
{
if (!m_aDocIdle.IsActive())
if (m_nIdleBlockCount > 0)
m_bStartOnUnblock = true;
else if (!m_aDocIdle.IsActive())
m_aDocIdle.Start();
}
void DocumentTimerManager::StopIdling()
{
m_bStartOnUnblock = false;
m_aDocIdle.Stop();
}
void DocumentTimerManager::BlockIdling()
{
assert(SAL_MAX_UINT32 != m_nIdleBlockCount);
if (0 == m_nIdleBlockCount)
{
assert(!m_bStartOnUnblock);
m_bStartOnUnblock = false;
}
++m_nIdleBlockCount;
}
@@ -68,9 +77,13 @@ void DocumentTimerManager::UnblockIdling()
assert(0 != m_nIdleBlockCount);
--m_nIdleBlockCount;
// kick the active idle, if it's not anymore blocked by IsDocIdle()
if (m_aDocIdle.IsActive() && IsDocIdle())
m_aDocIdle.Start();
if ((0 == m_nIdleBlockCount) && m_bStartOnUnblock)
{
m_bStartOnUnblock = false;
// kick the active idle, if it's not anymore blocked by IsDocIdle()
if (IsDocIdle())
m_aDocIdle.Start();
}
}
DocumentTimerManager::IdleJob DocumentTimerManager::GetNextIdleJob() const
@@ -67,6 +67,7 @@ private:
SwDoc& m_rDoc;
sal_uInt32 m_nIdleBlockCount; ///< Don't run the Idle, if > 0
bool m_bStartOnUnblock; ///< true, if the last unblock should start the timer
SwDocIdle m_aDocIdle;
};