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

diff --git a/framework/source/uielement/toolbarmodemenucontroller.cxx 
b/framework/source/uielement/toolbarmodemenucontroller.cxx
index 62cfdc04dd41..9b8c1db1683b 100644
--- a/framework/source/uielement/toolbarmodemenucontroller.cxx
+++ b/framework/source/uielement/toolbarmodemenucontroller.cxx
@@ -277,7 +277,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 e19a7ec40b00..887785aee936 100644
--- a/framework/source/uielement/toolbarsmenucontroller.cxx
+++ b/framework/source/uielement/toolbarsmenucontroller.cxx
@@ -711,7 +711,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 61df2a4645af..692753e04b14 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