sw/inc/IDocumentTimerAccess.hxx             |   40 ++++++++++++++--------------
 sw/source/core/doc/DocumentTimerManager.cxx |   20 +++++++-------
 sw/source/core/inc/DocumentTimerManager.hxx |    3 --
 sw/source/core/inc/docfld.hxx               |    2 -
 sw/source/core/inc/rootfrm.hxx              |    4 +-
 5 files changed, 35 insertions(+), 34 deletions(-)

New commits:
commit d24d40f8f22d64cecbb707a930caed1da96d2dce
Author:     Jan-Marek Glogowski <glo...@fbihome.de>
AuthorDate: Fri Aug 17 23:10:00 2018 +0200
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Mon Nov 14 09:23:23 2022 +0100

    tdf#116370 cleanup Writer idle job handing
    
    This prevents the start of the idle job, while processing itself,
    so the fixed WinSalInstance::AnyInput of commit 3bf6c97029d2
    ("tdf#112975 WIN correctly handle VclInputFlags::OTHER") won't
    report the timer events of the re-started idle job to process.
    
    Fixes the early abort of the background job, which resulted in
    the busy loop of the reported bug and this strange printing
    behaviour.
    
    P.S. I'm not sure, why this was just broken on Windows.
    
    Reviewed-on: https://gerrit.libreoffice.org/59279
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glo...@fbihome.de>
    (cherry picked from commit 401cba4c20fbc930f034168872642428d7459218)
    
    Change-Id: I6503dcd925c9a0ed843e794a31eea32a4a4b2889

diff --git a/sw/inc/IDocumentTimerAccess.hxx b/sw/inc/IDocumentTimerAccess.hxx
index 2cdb33e5ab7d..d28e2ef9b1a3 100644
--- a/sw/inc/IDocumentTimerAccess.hxx
+++ b/sw/inc/IDocumentTimerAccess.hxx
@@ -20,41 +20,43 @@
 #ifndef INCLUDED_SW_INC_IDOCUMENTTIMERACCESS_HXX
 #define INCLUDED_SW_INC_IDOCUMENTTIMERACCESS_HXX
 
-/** Manipulate background jobs of the document. It starts with a mode of
- 'started' and a block count of 0.
+/**
+ * Handle the background job of the Writer document.
+ *
+ * Initially it's disabled and unblocked.
+ *
+ * Jobs include:
+ *  * grammar checking
+ *  * field updating
+ *  * document layouting
  */
 class IDocumentTimerAccess
 {
 public:
     /**
-    Set modus to 'start'.
-    */
+     * Start the idle job depending on the block count.
+     */
     virtual void StartIdling() = 0;
 
     /**
-    Set mode to 'stopped'.
-    */
+     * Stop idle processing.
+     */
     virtual void StopIdling() = 0;
 
     /**
-    Increment block count.
-    */
+     * Increment block count.
+     *
+     * Prevents further background idle processing.
+     */
     virtual void BlockIdling() = 0;
 
     /**
-    Decrement block count.
-    */
+     * Decrement block count.
+     *
+     * May start the idle job.
+     */
     virtual void UnblockIdling() = 0;
 
-    /**
-    Do these jobs asynchronously: do grammar checking,
-    do layout, and update fields.
-    They will be delayed until mode is start AND block count == 0.
-    The implementation might delay them further, for example
-    it might wait until the application is idle.
-    */
-    virtual void StartBackgroundJobs() = 0;
-
 protected:
     virtual ~IDocumentTimerAccess() {};
 };
diff --git a/sw/source/core/doc/DocumentTimerManager.cxx 
b/sw/source/core/doc/DocumentTimerManager.cxx
index 83ce6fe2dce9..652672859203 100644
--- a/sw/source/core/doc/DocumentTimerManager.cxx
+++ b/sw/source/core/doc/DocumentTimerManager.cxx
@@ -49,9 +49,13 @@ DocumentTimerManager::DocumentTimerManager( SwDoc& i_rSwdoc 
) : m_rDoc( i_rSwdoc
 
 void DocumentTimerManager::StartIdling()
 {
-    mbStartIdleTimer = true;
-    if( !mIdleBlockCount )
+    if( !mIdleBlockCount && !maIdle.IsActive() )
+    {
+        mbStartIdleTimer = false;
         maIdle.Start();
+    }
+    else
+        mbStartIdleTimer = true;
 }
 
 void DocumentTimerManager::StopIdling()
@@ -70,14 +74,10 @@ void DocumentTimerManager::UnblockIdling()
 {
     --mIdleBlockCount;
     if( !mIdleBlockCount && mbStartIdleTimer && !maIdle.IsActive() )
+    {
+        mbStartIdleTimer = false;
         maIdle.Start();
-}
-
-void DocumentTimerManager::StartBackgroundJobs()
-{
-    // Trigger DoIdleJobs(), asynchronously.
-    if (!maIdle.IsActive()) //fdo#73165 if the timer is already running don't 
restart from 0
-        maIdle.Start();
+    }
 }
 
 IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, void )
@@ -87,6 +87,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, 
void )
     if( !pModLogFile )
         pModLogFile = new ::rtl::Logfile( "First DoIdleJobs" );
 #endif
+    BlockIdling();
 
     SwRootFrame* pTmpRoot = 
m_rDoc.getIDocumentLayoutAccess().GetCurrentLayout();
     if( pTmpRoot &&
@@ -163,6 +164,7 @@ IMPL_LINK( DocumentTimerManager, DoIdleJobs, Timer*, pIdle, 
void )
             
m_rDoc.getIDocumentFieldsAccess().GetUpdateFields().SetFieldsDirty( false );
         }
     }
+
 #ifdef TIMELOG
     if( pModLogFile && 1 != (long)pModLogFile )
         delete pModLogFile, static_cast<long&>(pModLogFile) = 1;
diff --git a/sw/source/core/inc/DocumentTimerManager.hxx 
b/sw/source/core/inc/DocumentTimerManager.hxx
index da4b9e4b30fd..e4ce83a8f233 100644
--- a/sw/source/core/inc/DocumentTimerManager.hxx
+++ b/sw/source/core/inc/DocumentTimerManager.hxx
@@ -45,9 +45,6 @@ public:
 
     void UnblockIdling() override;
 
-    void StartBackgroundJobs() override;
-
-    // Our own 'IdleTimer' calls the following method
     DECL_LINK( DoIdleJobs, Timer *, void );
 
     virtual ~DocumentTimerManager() override;
diff --git a/sw/source/core/inc/docfld.hxx b/sw/source/core/inc/docfld.hxx
index 5410ed76f52a..01bfa8c28506 100644
--- a/sw/source/core/inc/docfld.hxx
+++ b/sw/source/core/inc/docfld.hxx
@@ -168,7 +168,7 @@ public:
 
         if (b)
         {
-            pDocument->getIDocumentTimerAccess().StartBackgroundJobs();
+            pDocument->getIDocumentTimerAccess().StartIdling();
         }
     }
 
diff --git a/sw/source/core/inc/rootfrm.hxx b/sw/source/core/inc/rootfrm.hxx
index ad5f7595ab93..718c68d4acec 100644
--- a/sw/source/core/inc/rootfrm.hxx
+++ b/sw/source/core/inc/rootfrm.hxx
@@ -240,7 +240,7 @@ public:
         // May be NULL if called from SfxBaseModel::dispose
         // (this happens in the build test 'rtfexport').
         if (pCurrShell != nullptr)
-            
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
+            pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
     }
     bool IsIdleFormat()  const { return mbIdleFormat; }
     void ResetIdleFormat()     { mbIdleFormat = false; }
@@ -256,7 +256,7 @@ public:
             // May be NULL if called from SfxBaseModel::dispose
             // (this happens in the build test 'rtfexport').
             if (pCurrShell != nullptr)
-                
pCurrShell->GetDoc()->getIDocumentTimerAccess().StartBackgroundJobs();
+                pCurrShell->GetDoc()->getIDocumentTimerAccess().StartIdling();
         }
     }
 

Reply via email to