summaryrefslogtreecommitdiff
path: root/framework/source/uielement/popuptoolbarcontroller.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'framework/source/uielement/popuptoolbarcontroller.cxx')
-rw-r--r--framework/source/uielement/popuptoolbarcontroller.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/framework/source/uielement/popuptoolbarcontroller.cxx b/framework/source/uielement/popuptoolbarcontroller.cxx
index b04c831e7a12..34b3a39cf528 100644
--- a/framework/source/uielement/popuptoolbarcontroller.cxx
+++ b/framework/source/uielement/popuptoolbarcontroller.cxx
@@ -200,7 +200,13 @@ PopupMenuToolbarController::createPopupWindow()
pToolBox->SetItemDown( m_nToolBoxId, true );
WindowAlign eAlign( pToolBox->GetAlign() );
- sal_uInt16 nId = m_xPopupMenu->execute(
+
+ // If the parent ToolBox is in popup mode (e.g. sub toolbar, overflow popup),
+ // its ToolBarManager can be disposed along with our controller, destroying
+ // m_xPopupMenu, while the latter still in execute. This should be fixed at a
+ // different level, for now just hold it here so it won't crash.
+ css::uno::Reference< css::awt::XPopupMenu > xPopupMenu ( m_xPopupMenu );
+ sal_uInt16 nId = xPopupMenu->execute(
css::uno::Reference< css::awt::XWindowPeer >( getParent(), css::uno::UNO_QUERY ),
VCLUnoHelper::ConvertToAWTRect( pToolBox->GetItemRect( m_nToolBoxId ) ),
( eAlign == WindowAlign::Top || eAlign == WindowAlign::Bottom ) ?
@@ -209,7 +215,7 @@ PopupMenuToolbarController::createPopupWindow()
pToolBox->SetItemDown( m_nToolBoxId, false );
if ( nId )
- functionExecuted( m_xPopupMenu->getCommand( nId ) );
+ functionExecuted( xPopupMenu->getCommand( nId ) );
return xRet;
}