desktop/inc/lib/init.hxx        |    1 +
 desktop/source/lib/init.cxx     |    6 ++++++
 include/editeng/outliner.hxx    |    1 +
 include/sfx2/lokcallback.hxx    |    3 +++
 include/sfx2/viewsh.hxx         |    5 +++--
 include/test/lokcallback.hxx    |    1 +
 sfx2/source/view/viewsh.cxx     |   10 ++++++++++
 sw/source/core/view/viewimp.cxx |    5 ++++-
 test/source/lokcallback.cxx     |    6 ++++++
 9 files changed, 35 insertions(+), 3 deletions(-)

New commits:
commit 32cbd1c57dbaf7cff2325c126b3adfcf2150bc23
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Jun 28 09:42:17 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Thu Aug 25 10:28:35 2022 +0200

    lok: make sure flushPendingLOKInvalidateTiles() is called
    
    SwViewShellImp::AddPendingLOKInvalidation() collects invalidations,
    but this was relying on something eventually calling
    flushPendingLOKInvalidateTiles(), which wasn't guaranteed.
    If e.g. a spellchecker caused an invalidation from in idle callback
    and nothing else changed, then the LOK callback handling code
    didn't know there was something pending. So add an explicit
    call to ensure to notify about these pending invalidations.
    
    Change-Id: I0a9cb0d5aba2fdbbac126cd8a4a3412bef1cab25
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136531
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 78c74c753063..2b21f6a6d30a 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -118,6 +118,7 @@ namespace desktop {
         virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) override;
         virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
         virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) override;
+        virtual void libreOfficeKitViewAddPendingInvalidateTiles() override;
         virtual void dumpState(rtl::OStringBuffer &rState) override;
 
     private:
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 91f6b771a8f1..54b72d7ef88f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1486,6 +1486,12 @@ void CallbackFlushHandler::dumpState(rtl::OStringBuffer 
&rState)
     }
 }
 
+void CallbackFlushHandler::libreOfficeKitViewAddPendingInvalidateTiles()
+{
+    // Invoke() will call flushPendingLOKInvalidateTiles(), so just make sure 
the timer is active.
+    startTimer();
+}
+
 void CallbackFlushHandler::queue(const int type, const char* data)
 {
     CallbackData callbackData(data);
diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx
index 3326a3d6662b..1712c1f3d427 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -373,6 +373,7 @@ public:
     virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) const = 0;
     virtual void libreOfficeKitViewUpdatedCallback(int nType) const = 0;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) const = 0;
+    virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0;
     virtual ViewShellId GetViewShellId() const = 0;
     virtual ViewShellDocId GetDocId() const = 0;
     /// Wrapper around SfxLokHelper::notifyOtherViews().
diff --git a/include/sfx2/lokcallback.hxx b/include/sfx2/lokcallback.hxx
index a92f60572145..cf97f083e792 100644
--- a/include/sfx2/lokcallback.hxx
+++ b/include/sfx2/lokcallback.hxx
@@ -50,6 +50,9 @@ public:
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId,
                                                             int nSourceViewId)
         = 0;
+    // There are pending invalidate tiles calls that need to be processed.
+    // A call to SfxViewShell::flushPendingLOKInvalidateTiles() should be 
scheduled.
+    virtual void libreOfficeKitViewAddPendingInvalidateTiles() = 0;
     virtual void dumpState(rtl::OStringBuffer& rState) = 0;
 };
 
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 9762c6cd6e03..28b4c190cdc8 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -350,10 +350,11 @@ public:
     virtual void libreOfficeKitViewCallback(int nType, const char* pPayload) 
const override;
     virtual void libreOfficeKitViewCallbackWithViewId(int nType, const char* 
pPayload, int nViewId) const override;
     virtual void libreOfficeKitViewInvalidateTilesCallback(const 
tools::Rectangle* pRect, int nPart) const override;
-    // Performs any pending calls to 
libreOfficeKitViewInvalidateTilesCallback() as necessary.
-    virtual void flushPendingLOKInvalidateTiles();
     virtual void libreOfficeKitViewUpdatedCallback(int nType) const override;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId, int nSourceViewId) const override;
+    // Performs any pending calls to 
libreOfficeKitViewInvalidateTilesCallback() as necessary.
+    virtual void flushPendingLOKInvalidateTiles();
+    virtual void libreOfficeKitViewAddPendingInvalidateTiles() override;
     // Returns current payload for nType, after 
libreOfficeKitViewUpdatedCallback() or
     // libreOfficeKitViewUpdatedCallbackPerViewId() were called. If no payload 
should
     // be generated, the ignore flag should be set.
diff --git a/include/test/lokcallback.hxx b/include/test/lokcallback.hxx
index e18724279040..75a8977938bc 100644
--- a/include/test/lokcallback.hxx
+++ b/include/test/lokcallback.hxx
@@ -39,6 +39,7 @@ public:
     virtual void libreOfficeKitViewUpdatedCallback(int nType) override;
     virtual void libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int 
nViewId,
                                                             int nSourceViewId) 
override;
+    virtual void libreOfficeKitViewAddPendingInvalidateTiles() override;
     virtual void dumpState(rtl::OStringBuffer&) override{};
 
     virtual void Invoke() override;
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index f79d5f78ee9b..4dfe4596b3ce 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1546,6 +1546,16 @@ void 
SfxViewShell::libreOfficeKitViewUpdatedCallbackPerViewId(int nType, int nVi
             << lokCallbackTypeToString(nType));
 }
 
+void SfxViewShell::libreOfficeKitViewAddPendingInvalidateTiles()
+{
+    if (pImpl->m_pLibreOfficeKitViewCallback)
+        
pImpl->m_pLibreOfficeKitViewCallback->libreOfficeKitViewAddPendingInvalidateTiles();
+    else
+        SAL_INFO(
+            "sfx.view",
+            "SfxViewShell::libreOfficeKitViewAddPendingInvalidateTiles no 
callback set!");
+}
+
 void SfxViewShell::afterCallbackRegistered()
 {
 }
diff --git a/sw/source/core/view/viewimp.cxx b/sw/source/core/view/viewimp.cxx
index c048f578816f..3beb58c448d0 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -37,6 +37,7 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <drawdoc.hxx>
 #include <prevwpage.hxx>
+#include <sfx2/viewsh.hxx>
 
 void SwViewShellImp::Init( const SwViewOption *pNewOpt )
 {
@@ -164,8 +165,10 @@ bool SwViewShellImp::AddPaintRect( const SwRect &rRect )
 
 void SwViewShellImp::AddPendingLOKInvalidation( const SwRect& rRect )
 {
-    // These are often repeated, so check first for duplicates.
     std::vector<SwRect>& l = m_pendingLOKInvalidations;
+    if(l.empty()) // Announce that these invalidations will need flushing.
+        
m_pShell->GetSfxViewShell()->libreOfficeKitViewAddPendingInvalidateTiles();
+    // These are often repeated, so check first for duplicates.
     if( std::find( l.begin(), l.end(), rRect ) == l.end())
         l.push_back( rRect );
 }
diff --git a/test/source/lokcallback.cxx b/test/source/lokcallback.cxx
index c938e1e699a8..d7500cb74443 100644
--- a/test/source/lokcallback.cxx
+++ b/test/source/lokcallback.cxx
@@ -106,6 +106,12 @@ void 
TestLokCallbackWrapper::libreOfficeKitViewUpdatedCallbackPerViewId(int nTyp
     startTimer();
 }
 
+void TestLokCallbackWrapper::libreOfficeKitViewAddPendingInvalidateTiles()
+{
+    // Invoke() will call flushPendingLOKInvalidateTiles().
+    startTimer();
+}
+
 void TestLokCallbackWrapper::discardUpdatedTypes(int nType, int nViewId)
 {
     // If a callback is called directly with an event, drop the updated flag 
for it, since

Reply via email to