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 fc856cd46ac475222772395c522dc34058bd89b9
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Jun 28 09:42:17 2022 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Aug 31 08:37:06 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/+/136533
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 8b26e117c1fb..6a6f0bd350a3 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -115,6 +115,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;
 
     private:
         struct CallbackData
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 4abe6f2c5166..f22558d6d76e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1477,6 +1477,12 @@ void 
CallbackFlushHandler::libreOfficeKitViewUpdatedCallbackPerViewId(int nType,
     setUpdatedTypePerViewId(nType, nViewId, nSourceViewId, true);
 }
 
+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 8cc3e8c23247..e7e9720ad432 100644
--- a/include/editeng/outliner.hxx
+++ b/include/editeng/outliner.hxx
@@ -369,6 +369,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 6f59402d0cec..b1799386d42b 100644
--- a/include/sfx2/lokcallback.hxx
+++ b/include/sfx2/lokcallback.hxx
@@ -48,6 +48,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;
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/include/sfx2/viewsh.hxx b/include/sfx2/viewsh.hxx
index 26a2324c7ca0..f2b0bf29080a 100644
--- a/include/sfx2/viewsh.hxx
+++ b/include/sfx2/viewsh.hxx
@@ -340,10 +340,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 a3f383bcec5e..f12840ec3484 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 Invoke() override;
 
 private:
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index 292f6f4fe096..63a547b8352f 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1544,6 +1544,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 c8cacafca5ea..55add5aea29b 100644
--- a/sw/source/core/view/viewimp.cxx
+++ b/sw/source/core/view/viewimp.cxx
@@ -36,6 +36,7 @@
 #include <IDocumentDrawModelAccess.hxx>
 #include <drawdoc.hxx>
 #include <prevwpage.hxx>
+#include <sfx2/viewsh.hxx>
 
 void SwViewShellImp::Init( const SwViewOption *pNewOpt )
 {
@@ -166,8 +167,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 440aae461eee..e9d61486ee0f 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