diff options
author | Patrick Luby <guibmacdev@gmail.com> | 2024-11-04 18:22:58 -0500 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-11-05 09:42:37 +0100 |
commit | 8dce42a2923c81ad88a1c7bfa27b75917701dd24 (patch) | |
tree | 4d0960133f862bbbd1e0619fa2452e749e91d4df | |
parent | 9fc54b966b2b9d423cf594cd385224b06986666f (diff) |
Fix crash due to unexpected dynamic_cast failures in optimized build
When an optimized build of this branch is compiled on Silicon Mac,
a dynamic_cast from com.sun.star.awt.XPopupMenu to VCLXPopupMenu
will fail.
The pointer being casted has not been deleted and is an undeleted
instance yet dynamic_cast fails. However, a dynamic_cast to
VCLXPopupMenu's superclass VCLXMenu succeeds so cast to that class
instead.
Change-Id: Ie9ab79df109eece46351545a71325d1e37bde94d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175994
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
4 files changed, 5 insertions, 4 deletions
diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx b/framework/source/uielement/toolbarmodemenucontroller.cxx index 1b6c9964b698..11bf5d787866 100644 --- a/framework/source/uielement/toolbarmodemenucontroller.cxx +++ b/framework/source/uielement/toolbarmodemenucontroller.cxx @@ -274,7 +274,7 @@ void SAL_CALL ToolbarModeMenuController::setPopupMenu( const Reference< css::awt // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + m_xPopupMenu = dynamic_cast<VCLXMenu*>(xPopupMenu.get()); assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) ); fillPopupMenu( m_xPopupMenu ); diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 9e5055ccfd37..ea96810613df 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -707,7 +707,7 @@ void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::X // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + m_xPopupMenu = dynamic_cast<VCLXMenu*>(xPopupMenu.get()); assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >(this) ); fillPopupMenu( m_xPopupMenu ); diff --git a/include/svtools/popupmenucontrollerbase.hxx b/include/svtools/popupmenucontrollerbase.hxx index b484aafd7a06..c27c203ac3eb 100644 --- a/include/svtools/popupmenucontrollerbase.hxx +++ b/include/svtools/popupmenucontrollerbase.hxx @@ -33,6 +33,7 @@ #include <comphelper/compbase.hxx> #include <rtl/ref.hxx> #include <rtl/ustring.hxx> +#include <toolkit/awt/vclxmenu.hxx> namespace com :: sun :: star :: frame { class XFrame; } namespace com :: sun :: star :: uno { class XComponentContext; } @@ -118,7 +119,7 @@ namespace svt css::uno::Reference< css::frame::XDispatch > m_xDispatch; css::uno::Reference< css::frame::XFrame > m_xFrame; css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - rtl::Reference< VCLXPopupMenu > m_xPopupMenu; + rtl::Reference< VCLXMenu > m_xPopupMenu; comphelper::OInterfaceContainerHelper4<XStatusListener> maStatusListeners; }; } diff --git a/svtools/source/uno/popupmenucontrollerbase.cxx b/svtools/source/uno/popupmenucontrollerbase.cxx index 85065724f9f3..2806efef204d 100644 --- a/svtools/source/uno/popupmenucontrollerbase.cxx +++ b/svtools/source/uno/popupmenucontrollerbase.cxx @@ -343,7 +343,7 @@ void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< awt::XPopu // Create popup menu on demand SolarMutexGuard aSolarMutexGuard; - m_xPopupMenu = dynamic_cast<VCLXPopupMenu*>(xPopupMenu.get()); + m_xPopupMenu = dynamic_cast<VCLXMenu*>(xPopupMenu.get()); assert(bool(xPopupMenu) == bool(m_xPopupMenu) && "we only support VCLXPopupMenu"); m_xPopupMenu->addMenuListener( Reference< awt::XMenuListener >(this) ); |