include/vcl/menu.hxx | 2 +- vcl/source/window/menu.cxx | 16 +++++++--------- vcl/source/window/syswin.cxx | 12 +++++++----- 3 files changed, 15 insertions(+), 15 deletions(-)
New commits: commit 6c48547069afa15b0f0dfedb5ac6b87fe54d160f Author: Michael Weghorn <[email protected]> AuthorDate: Mon Dec 2 14:28:47 2024 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Dec 2 19:28:12 2024 +0100 vcl: Simplify MenuBar::ImplDestroy a bit MenuBar::GetWindow() and MenuBar::getMenuBarWindow return a pointer to the same object, so there's no need to use + check both for null. Change-Id: I1b7065e4cd04a24e6215118a8dc71f147ed75132 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177699 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 1a9bb0deff38..40a946bbdf8a 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2509,13 +2509,11 @@ VclPtr<MenuBarWindow> MenuBar::ImplCreate(vcl::Window* pParent, MenuBarWindow* p void MenuBar::ImplDestroy( MenuBar* pMenu, bool bDelete ) { - vcl::Window *pWindow = pMenu->GetWindow(); - if (pWindow && bDelete) + MenuBarWindow* pMenuWin = pMenu->getMenuBarWindow(); + if (pMenuWin && bDelete) { - MenuBarWindow* pMenuWin = pMenu->getMenuBarWindow(); - if (pMenuWin) - pMenuWin->KillActivePopup(); - pWindow->disposeOnce(); + pMenuWin->KillActivePopup(); + pMenuWin->disposeOnce(); } pMenu->m_pWindow = nullptr; if (pMenu->mpSalMenu) { commit 228f40c5f6c9f5c707f92bbfddb128eacdaf2a8b Author: Michael Weghorn <[email protected]> AuthorDate: Mon Dec 2 14:25:45 2024 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Dec 2 19:28:02 2024 +0100 vcl: Drop unnecessary null check pMenuBarWindow is non-null and was already dereferenced earlier anyway. Change-Id: Ieaeda4129d5c819fefa37dd3a186f76e035961b9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177698 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 6bc427ba28f3..1a9bb0deff38 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2494,7 +2494,7 @@ VclPtr<MenuBarWindow> MenuBar::ImplCreate(vcl::Window* pParent, MenuBarWindow* p pMenu->pStartedFrom = nullptr; pMenu->m_pWindow = pMenuBarWindow; pMenuBarWindow->SetMenu(pMenu); - tools::Long nHeight = pMenuBarWindow ? pMenu->ImplCalcSize(pMenuBarWindow).Height() : 0; + tools::Long nHeight = pMenu->ImplCalcSize(pMenuBarWindow).Height(); // depending on the native implementation or the displayable flag // the menubar windows is suppressed (ie, height=0) commit 185f7fa290d2d7e6f79b543acdc239323f727a5e Author: Michael Weghorn <[email protected]> AuthorDate: Mon Dec 2 14:20:20 2024 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Mon Dec 2 19:27:56 2024 +0100 vcl: Switch MenuBar::ImplCreate param to MenuBarWindow* This avoids the need to do a dynamic_cast and makes clear that this method always gets called with either a window of a proper type or nullptr. Change-Id: I8ca4020476c806ad423379c7c7ee6fdc6ceccd3a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177697 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index b60cdc42b39b..36259d5ffb7f 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -421,7 +421,7 @@ class VCL_DLLPUBLIC MenuBar final : public Menu friend class MenuBarWindow; friend class SystemWindow; - SAL_DLLPRIVATE static VclPtr<vcl::Window> ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu); + SAL_DLLPRIVATE static VclPtr<MenuBarWindow> ImplCreate(vcl::Window* pParent, MenuBarWindow* pWindow, MenuBar* pMenu); SAL_DLLPRIVATE static void ImplDestroy(MenuBar* pMenu, bool bDelete); SAL_DLLPRIVATE bool ImplHandleKeyEvent(const KeyEvent& rKEvent); SAL_DLLPRIVATE bool ImplHandleCmdEvent(const CommandEvent& rCEvent); diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index ff6581d207a9..6bc427ba28f3 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -2483,9 +2483,9 @@ void MenuBar::SetDisplayable( bool bDisplayable ) } } -VclPtr<vcl::Window> MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWindow, MenuBar* pMenu) +VclPtr<MenuBarWindow> MenuBar::ImplCreate(vcl::Window* pParent, MenuBarWindow* pWindow, MenuBar* pMenu) { - VclPtr<MenuBarWindow> pMenuBarWindow = dynamic_cast<MenuBarWindow*>(pWindow); + VclPtr<MenuBarWindow> pMenuBarWindow = pWindow; if (!pMenuBarWindow) { pMenuBarWindow = VclPtr<MenuBarWindow>::Create(pParent); diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index d4e1f9e51997..e92806e739fe 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -19,6 +19,8 @@ #include <memory> +#include "menubarwindow.hxx" + #include <o3tl/safeint.hxx> #include <sal/config.h> #include <sal/log.hxx> @@ -844,14 +846,14 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) return; MenuBar* pOldMenuBar = mpMenuBar; - vcl::Window* pOldWindow = nullptr; - VclPtr<vcl::Window> pNewWindow; + MenuBarWindow* pOldWindow = nullptr; + VclPtr<MenuBarWindow> pNewWindow; mpMenuBar = pMenuBar; if ( mpWindowImpl->mpBorderWindow && (mpWindowImpl->mpBorderWindow->GetType() == WindowType::BORDERWINDOW) ) { if ( pOldMenuBar ) - pOldWindow = pOldMenuBar->GetWindow(); + pOldWindow = pOldMenuBar->getMenuBarWindow(); else pOldWindow = nullptr; if ( pOldWindow ) @@ -888,9 +890,9 @@ void SystemWindow::SetMenuBar(MenuBar* pMenuBar) else { if( pMenuBar ) - pNewWindow = pMenuBar->GetWindow(); + pNewWindow = pMenuBar->getMenuBarWindow(); if( pOldMenuBar ) - pOldWindow = pOldMenuBar->GetWindow(); + pOldWindow = pOldMenuBar->getMenuBarWindow(); } // update taskpane list to make menubar accessible
