sw/source/core/doc/DocumentTimerManager.cxx |   21 +++++++++++++++++----
 sw/source/core/inc/DocumentTimerManager.hxx |    1 +
 2 files changed, 18 insertions(+), 4 deletions(-)

New commits:
commit 771544544ee13ec98961f93b5313a7d2e29429cd
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Tue Aug 28 10:13:28 2018 +0200
Commit:     Jan-Marek Glogowski <glo...@fbihome.de>
CommitDate: Tue Aug 28 13:13:12 2018 +0200

    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 <glo...@fbihome.de>

diff --git a/sw/source/core/doc/DocumentTimerManager.cxx 
b/sw/source/core/doc/DocumentTimerManager.cxx
index 6195b8fdf961..81c46b125840 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -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
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx 
b/sw/source/core/inc/DocumentTimerManager.hxx
index e04e0602cc4f..2caaf608c40d 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -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;
 };
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to