[Libreoffice-commits] core.git: compilerplugins/clang desktop/inc desktop/source

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Tue Dec 3 08:48:40 UTC 2019


 compilerplugins/clang/unusedmethods.results |    6 ----
 desktop/inc/lib/init.hxx                    |   19 +++++++--------
 desktop/source/lib/init.cxx                 |   34 +++++++++++++++++++---------
 3 files changed, 33 insertions(+), 26 deletions(-)

New commits:
commit b31c39cbc843e77c8d97dbb2e559b48b21202ba6
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Nov 30 18:14:06 2019 -0500
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Dec 3 09:47:25 2019 +0100

    desktop: disable callback handling while changing the view
    
    When changing the view, some components are disabled
    and re-enabled. This triggers a flood of invalidations
    that then result in rendering requests. For each rendering
    the view is set, which triggers more invalidations.
    
    The Sidebar suffers from this, and it causes cpu pegging.
    This fix prevents this issue by disabling all callbacks
    during setView.
    
    Change-Id: If6b93b2ab31f568a0761f15d945a43de1bc2d4d0
    Reviewed-on: https://gerrit.libreoffice.org/84184
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>
    Reviewed-on: https://gerrit.libreoffice.org/84226
    Tested-by: Jenkins
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/compilerplugins/clang/unusedmethods.results b/compilerplugins/clang/unusedmethods.results
index 39f442e6206d..9b83e3676a05 100644
--- a/compilerplugins/clang/unusedmethods.results
+++ b/compilerplugins/clang/unusedmethods.results
@@ -128,12 +128,6 @@ dbaccess/source/ui/inc/SqlNameEdit.hxx:105
     void dbaui::OSQLNameEntry::set_sensitive(_Bool)
 dbaccess/source/ui/inc/WTypeSelect.hxx:76
     void dbaui::OWizTypeSelectList::show()
-desktop/inc/lib/init.hxx:83
-    void desktop::CallbackFlushHandler::setEventLatch(const _Bool)
-desktop/inc/lib/init.hxx:88
-    _Bool desktop::CallbackFlushHandler::isEventLatchOn() const
-desktop/inc/lib/init.hxx:90
-    _Bool desktop::CallbackFlushHandler::isPartTilePainting() const
 desktop/source/lib/lokclipboard.hxx:96
      LOKClipboardFactory::LOKClipboardFactory()
 drawinglayer/source/tools/emfpcustomlinecap.hxx:38
diff --git a/desktop/inc/lib/init.hxx b/desktop/inc/lib/init.hxx
index 3587ba003e37..5957f56ed344 100644
--- a/desktop/inc/lib/init.hxx
+++ b/desktop/inc/lib/init.hxx
@@ -79,15 +79,14 @@ namespace desktop {
         static void callback(const int type, const char* payload, void* data);
         void queue(const int type, const char* data);
 
-        /// When enabled events are queued but callback not invoked.
-        void setEventLatch(const bool bEventLatch)
-        {
-            m_bEventLatch = bEventLatch;
-        }
-
-        bool isEventLatchOn() const { return m_bEventLatch; }
-        void setPartTilePainting(const bool bPartPainting) { m_bPartTilePainting = bPartPainting; }
-        bool isPartTilePainting() const { return m_bPartTilePainting; }
+        /// Disables callbacks on this handler. Must match with identical count
+        /// of enableCallbacks. Used during painting and changing views.
+        void disableCallbacks() { ++m_nDisableCallbacks; }
+        /// Enables callbacks on this handler. Must match with identical count
+        /// of disableCallbacks. Used during painting and changing views.
+        void enableCallbacks() { --m_nDisableCallbacks; }
+        /// Returns true iff callbacks are disabled.
+        bool callbacksDisabled() const { return m_nDisableCallbacks != 0; }
 
         void addViewStates(int viewId);
         void removeViewStates(int viewId);
@@ -140,7 +139,7 @@ namespace desktop {
         LibreOfficeKitDocument* m_pDocument;
         LibreOfficeKitCallback m_pCallback;
         void *m_pData;
-        bool m_bPartTilePainting;
+        int m_nDisableCallbacks;
         bool m_bEventLatch;
         std::mutex m_mutex;
     };
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 7ecc9fcdf78b..e5f9d6893bf2 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1084,7 +1084,7 @@ CallbackFlushHandler::CallbackFlushHandler(LibreOfficeKitDocument* pDocument, Li
       m_pDocument(pDocument),
       m_pCallback(pCallback),
       m_pData(pData),
-      m_bPartTilePainting(false),
+      m_nDisableCallbacks(0),
       m_bEventLatch(false)
 {
     SetPriority(TaskPriority::POST_PAINT);
@@ -1134,7 +1134,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
         bIsChartActive = aChartHelper.GetWindow() != nullptr;
     }
 
-    if (m_bPartTilePainting && !bIsChartActive)
+    if (callbacksDisabled() && !bIsChartActive)
     {
         // We drop notifications when this is set, except for important ones.
         // When we issue a complex command (such as .uno:InsertAnnotation)
@@ -2854,9 +2854,9 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
     // Disable callbacks while we are painting.
     if (nOrigViewId >= 0)
     {
-        auto findIt = pDocument->mpCallbackFlushHandlers.find(nOrigViewId);
-        if (findIt != pDocument->mpCallbackFlushHandlers.end())
-            findIt->second->setPartTilePainting(true);
+        const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nOrigViewId);
+        if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+            handlerIt->second->disableCallbacks();
     }
 
     try
@@ -2909,9 +2909,9 @@ static void doc_paintPartTile(LibreOfficeKitDocument* pThis,
 
     if (nOrigViewId >= 0)
     {
-        auto findIt = pDocument->mpCallbackFlushHandlers.find(nOrigViewId);
-        if (findIt != pDocument->mpCallbackFlushHandlers.end())
-            findIt->second->setPartTilePainting(false);
+        const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nOrigViewId);
+        if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+            handlerIt->second->enableCallbacks();
     }
 }
 
@@ -4672,14 +4672,28 @@ static void doc_destroyView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis
     SfxLokHelper::destroyView(nId);
 }
 
-static void doc_setView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/, int nId)
+static void doc_setView(LibreOfficeKitDocument* pThis, int nId)
 {
     comphelper::ProfileZone aZone("doc_setView");
 
     SolarMutexGuard aGuard;
     SetLastExceptionMsg();
 
-    SfxLokHelper::setView(nId);
+    LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
+    const auto handlerIt = pDocument->mpCallbackFlushHandlers.find(nId);
+    if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+        handlerIt->second->disableCallbacks();
+
+    try
+    {
+        SfxLokHelper::setView(nId);
+    }
+    catch (const std::exception&)
+    {
+    }
+
+    if (handlerIt != pDocument->mpCallbackFlushHandlers.end())
+        handlerIt->second->enableCallbacks();
 }
 
 static int doc_getView(SAL_UNUSED_PARAMETER LibreOfficeKitDocument* /*pThis*/)


More information about the Libreoffice-commits mailing list