summaryrefslogtreecommitdiff
path: root/desktop/source
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-11-30 18:14:06 -0500
committerAshod Nakashian <ashnakash@gmail.com>2019-12-02 04:42:35 +0100
commit35aa4c881fc8c0c704530f042c31fbbe78a022f8 (patch)
tree10a83a0cdcf1b3bcfa032dac5061290adf9090a5 /desktop/source
parent47741aa17113efb1dcd002c1e1d81d66e16fd1cb (diff)
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@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'desktop/source')
-rw-r--r--desktop/source/lib/init.cxx34
1 files changed, 24 insertions, 10 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index b55fa59955f2..afbd4d283b35 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -1077,7 +1077,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);
@@ -1127,7 +1127,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)
@@ -2860,9 +2860,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
@@ -2915,9 +2915,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();
}
}
@@ -4665,14 +4665,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*/)