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

New commits:
commit a328316735a426f7d3dd468bfec5c47f9a9f96fe
Author:     Szymon Kłos <[email protected]>
AuthorDate: Mon Nov 14 16:11:55 2022 +0100
Commit:     Ashod Nakashian <[email protected]>
CommitDate: Wed Nov 16 12:44:55 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 <[email protected]>
    Reviewed-by: Ashod Nakashian <[email protected]>

diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 627c352c4b24..b02920240f3e 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -3826,7 +3826,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)
@@ -3862,6 +3863,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)
             {
@@ -3889,6 +3898,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