framework/source/uielement/subtoolbarcontroller.cxx | 28 +++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-)
New commits: commit dd7015ed5fc2eedf3b14278d55ddf29a50214542 Author: Caolán McNamara <[email protected]> AuthorDate: Thu Aug 4 11:45:47 2022 +0100 Commit: Caolán McNamara <[email protected]> CommitDate: Thu Aug 4 16:30:21 2022 +0200 tdf#150249 close of popover not detected 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/+/137732 Reviewed-by: Michael Stahl <[email protected]> Tested-by: Jenkins diff --git a/framework/source/uielement/subtoolbarcontroller.cxx b/framework/source/uielement/subtoolbarcontroller.cxx index e02e4631bd6b..8731f311b7b0 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<weld::Container> 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<WeldToolbarPopup> SubToolBarController::weldPopupWindow() { SolarMutexGuard aGuard; - auto pPopup = std::make_unique<SubToolbarControl>(getFrameInterface(), m_pToolbar); + auto pPopup = std::make_unique<SubToolbarControl>(*this, m_pToolbar); css::uno::Reference< css::frame::XFrame > xFrame ( getFrameInterface() ); @@ -268,10 +276,6 @@ std::unique_ptr<WeldToolbarPopup> SubToolBarController::weldPopupWindow() catch ( css::lang::IllegalArgumentException& ) {} - weld::Popover* pPopover = dynamic_cast<weld::Popover*>(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;
