desktop/source/lib/init.cxx |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

New commits:
commit bac26f91ae930902c336b1e5ceb08e1ae5de8d8a
Author:     Szymon Kłos <szymon.k...@collabora.com>
AuthorDate: Mon Nov 14 16:11:55 2022 +0100
Commit:     Szymon Kłos <szymon.k...@collabora.com>
CommitDate: Sat Nov 19 17:44:34 2022 +0100

    lok: masterpage: disable callbacks on painting
    
    We did that only for original view, but we need to disable
    callbacks for used view - so when we switch mode or part it
    will not send the notification to the client.
    
    Bug fixed by this patch:
    1. open impress in two LOK sessions
    2. A enters MasterPage mode
    3. B switched slide
    4. A exits MasterPage mode
    
    result: A was switched to the slide selected by B
    
    Change-Id: I7dde8bb4c73862813d064319922aba4c4b727db9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142716
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Ashod Nakashian <a...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142966
    Tested-by: Jenkins
    Reviewed-by: Szymon Kłos <szymon.k...@collabora.com>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 41f05517082f..1163ef2a638f 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3817,7 +3817,8 @@ static void doc_paintPartTile(LibreOfficeKitDocument* 
pThis,
     {
         // Text documents have a single coordinate system; don't change part.
         int nOrigPart = 0;
-        const bool isText = (doc_getDocumentType(pThis) == LOK_DOCTYPE_TEXT);
+        const int aType = doc_getDocumentType(pThis);
+        const bool isText = (aType == LOK_DOCTYPE_TEXT);
         int nViewId = nOrigViewId;
         int nLastNonEditorView = nViewId;
         if (!isText)
@@ -3853,6 +3854,14 @@ static void doc_paintPartTile(LibreOfficeKitDocument* 
pThis,
                 doc_setView(pThis, nLastNonEditorView);
             }
 
+            // Disable callbacks while we are painting - after setting the view
+            if (nViewId != nOrigViewId && nViewId >= 0)
+            {
+                const auto handlerIt = 
pDocument->mpCallbackFlushHandlers.find(nViewId);
+                if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+                    handlerIt->second->disableCallbacks();
+            }
+
             nOrigPart = doc_getPart(pThis);
             if (nPart != nOrigPart)
             {
@@ -3880,6 +3889,13 @@ static void doc_paintPartTile(LibreOfficeKitDocument* 
pThis,
         }
         if (!isText && nViewId != nOrigViewId)
         {
+            if (nViewId >= 0)
+            {
+                const auto handlerIt = 
pDocument->mpCallbackFlushHandlers.find(nViewId);
+                if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+                    handlerIt->second->enableCallbacks();
+            }
+
             doc_setView(pThis, nOrigViewId);
         }
     }

Reply via email to