From d84f7217b25bd3766497b17a8e057e3cbf4c8db8 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 4 Aug 2022 11:45:47 +0100 Subject: tdf#150249 close of popover not detected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the popover listened to here isn't the one that ends up getting actually used, its contents are transferred to another one, so the OnPopoverClosed wasn't called, its sufficient to just use the SubToolbarControl dtor to detect what is wanted here Change-Id: I3f4a038acfc183b863457919bf89d600517ddc01 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137792 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- .../source/uielement/subtoolbarcontroller.cxx | 28 ++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'framework') diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx index c5aed8f7bf59..de345f545497 100644 --- a/framework/source/uielement/subtoolbarcontroller.cxx +++ b/framework/source/uielement/subtoolbarcontroller.cxx @@ -46,7 +46,6 @@ namespace { class SubToolBarController : public ToolBarBase { - DECL_LINK(OnPopoverClose, weld::Popover&, void); OUString m_aSubTbName; OUString m_aLastCommand; css::uno::Reference< css::ui::XUIElement > m_xUIElement; @@ -56,6 +55,8 @@ public: const css::uno::Sequence< css::uno::Any >& rxArgs ); virtual ~SubToolBarController() override; + void PopoverDestroyed(); + // XInitialization virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& rxArgs ) override; @@ -209,22 +210,24 @@ namespace { class SubToolbarControl final : public WeldToolbarPopup { public: - explicit SubToolbarControl(css::uno::Reference< css::frame::XFrame > xFrame, - weld::Widget* pParent); + explicit SubToolbarControl(SubToolBarController& rController, weld::Widget* pParent); + virtual ~SubToolbarControl() override; virtual void GrabFocus() override; weld::Container* GetContainer() { return m_xTargetContainer.get(); } private: + SubToolBarController& m_rController; std::unique_ptr m_xTargetContainer; }; } -SubToolbarControl::SubToolbarControl(css::uno::Reference< css::frame::XFrame > xFrame, +SubToolbarControl::SubToolbarControl(SubToolBarController& rController, weld::Widget* pParent) -: WeldToolbarPopup(xFrame, pParent, "svt/ui/subtoolbar.ui", "subtoolbar") -, m_xTargetContainer(m_xBuilder->weld_container("container")) + : WeldToolbarPopup(rController.getFrameInterface(), pParent, "svt/ui/subtoolbar.ui", "subtoolbar") + , m_rController(rController) + , m_xTargetContainer(m_xBuilder->weld_container("container")) { } @@ -233,11 +236,16 @@ void SubToolbarControl::GrabFocus() // TODO } +SubToolbarControl::~SubToolbarControl() +{ + m_rController.PopoverDestroyed(); +} + std::unique_ptr SubToolBarController::weldPopupWindow() { SolarMutexGuard aGuard; - auto pPopup = std::make_unique(getFrameInterface(), m_pToolbar); + auto pPopup = std::make_unique(*this, m_pToolbar); css::uno::Reference< css::frame::XFrame > xFrame ( getFrameInterface() ); @@ -268,10 +276,6 @@ std::unique_ptr SubToolBarController::weldPopupWindow() catch ( css::lang::IllegalArgumentException& ) {} - weld::Popover* pPopover = dynamic_cast(pPopup->getTopLevel()); - if (pPopover) - pPopover->connect_closed(LINK(this, SubToolBarController, OnPopoverClose)); - return pPopup; } @@ -501,7 +505,7 @@ void SubToolBarController::initialize( const css::uno::Sequence< css::uno::Any > updateImage(); } -IMPL_LINK_NOARG(SubToolBarController, OnPopoverClose, weld::Popover&, void) +void SubToolBarController::PopoverDestroyed() { disposeUIElement(); m_xUIElement = nullptr; -- cgit