From 1d641165a9f632708da33d7853f88d335315dbf3 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Tue, 7 Dec 2021 15:47:37 +0100 Subject: do not unnecessarily lock XLayoutManager for menubar changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The XLayoutManager documentation says that lock() prohibits layout updates until unlock() is called, so it's not any kind of mutex or anything, it just allows grouping updates. Which means it's useless to put around a single call to change menubar visibility. To make things worse, unlock() will always trigger a layout, so even if nothing changes, it still does an unnecessary layout update. And since this gets called from SfxLokHelper::setView(), it may get called often and it's rather costly. Change-Id: I3e3e37b6763b15d454e76b4bef0b22f84cf479d5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126445 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos --- sfx2/source/notebookbar/SfxNotebookBar.cxx | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sfx2/source/notebookbar/SfxNotebookBar.cxx b/sfx2/source/notebookbar/SfxNotebookBar.cxx index dd6781ae66c3..e991ac9e6877 100644 --- a/sfx2/source/notebookbar/SfxNotebookBar.cxx +++ b/sfx2/source/notebookbar/SfxNotebookBar.cxx @@ -479,8 +479,6 @@ void SfxNotebookBar::ShowMenubar(bool bShow) if (xLayoutManager.is()) { - xLayoutManager->lock(); - if (xLayoutManager->getElement(MENUBAR_STR).is()) { if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) @@ -488,8 +486,6 @@ void SfxNotebookBar::ShowMenubar(bool bShow) else if(!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) xLayoutManager->showElement(MENUBAR_STR); } - - xLayoutManager->unlock(); } } } @@ -512,8 +508,6 @@ void SfxNotebookBar::ShowMenubar(SfxViewFrame const * pViewFrame, bool bShow) const Reference& xLayoutManager = lcl_getLayoutManager(xFrame); if (xLayoutManager.is()) { - xLayoutManager->lock(); - if (xLayoutManager->getElement(MENUBAR_STR).is()) { if (xLayoutManager->isElementVisible(MENUBAR_STR) && !bShow) @@ -521,8 +515,6 @@ void SfxNotebookBar::ShowMenubar(SfxViewFrame const * pViewFrame, bool bShow) else if (!xLayoutManager->isElementVisible(MENUBAR_STR) && bShow) xLayoutManager->showElement(MENUBAR_STR); } - - xLayoutManager->unlock(); } } m_bLock = false; -- cgit