summaryrefslogtreecommitdiff
path: root/desktop/inc
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2019-11-30 18:14:06 -0500
committerMichael Meeks <michael.meeks@collabora.com>2019-12-02 17:22:21 +0100
commit46722b2fc9e1021f3029f54291c18a598103cd12 (patch)
tree21d8084098bfed83a75d0d90d260ce679c508a2f /desktop/inc
parent2f463f9d1f45546318a57de57f6e5e918063af0a (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> Reviewed-on: https://gerrit.libreoffice.org/84224 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'desktop/inc')
-rw-r--r--desktop/inc/lib/init.hxx19
1 files changed, 9 insertions, 10 deletions
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;
};