framework/source/uielement/toolbarmodemenucontroller.cxx |    2 +-
 framework/source/uielement/toolbarsmenucontroller.cxx    |    2 +-
 include/svtools/popupmenucontrollerbase.hxx              |    3 ++-
 svtools/source/uno/popupmenucontrollerbase.cxx           |    2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 2fe53b2e436cb236b2dc121ceec4f22de49a13a8
Author:     Patrick Luby <guibmac...@gmail.com>
AuthorDate: Mon Nov 4 18:22:58 2024 -0500
Commit:     Caolán McNamara <caolan.mcnam...@collabora.com>
CommitDate: Tue Nov 5 09:42:12 2024 +0100

    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/+/175992
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Reviewed-by: Patrick Luby <guibomac...@gmail.com>

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 387eef47590b..764702adadc1 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -706,7 +706,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 228fd5bd4c8f..96ee5fb6f020 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 ab6bee1a0555..02d09d7d82a7 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) );
 

Reply via email to