diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2016-10-27 22:31:47 +0300 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2016-10-27 22:11:07 +0000 |
commit | 89c23b4aaef931b5d6009efaf44ce6e6c976e8d4 (patch) | |
tree | 73cb7691235d8c723ba5bc8add032daac0a6d53b | |
parent | 798c107a1afa6e22a0de97c49d0bda552913e56a (diff) |
Sub menus no longer need manual disposing
after:
commit ee79a2dd7ea60e902cab3a9203e307b8a78fee23
Author: Caolán McNamara <caolanm@redhat.com>
Date: Fri Jul 29 14:33:22 2016 +0100
Resolves: tdf#101169 crash using column menu in base
Change-Id: I7c6e54dd5574c61cffd5884d1cf1b63075073001
Reviewed-on: https://gerrit.libreoffice.org/30343
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Maxim Monastirsky <momonasmon@gmail.com>
-rw-r--r-- | cui/source/tabpages/numpages.cxx | 4 | ||||
-rw-r--r-- | cui/source/tabpages/tpline.cxx | 12 | ||||
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 2 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/sbagrid.hxx | 2 | ||||
-rw-r--r-- | include/svx/fmgridcl.hxx | 2 | ||||
-rw-r--r-- | include/vcl/menu.hxx | 1 | ||||
-rw-r--r-- | svtools/source/contnr/svimpbox.cxx | 15 | ||||
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 5 | ||||
-rw-r--r-- | sw/source/uibase/inc/workctrl.hxx | 3 | ||||
-rw-r--r-- | sw/source/uibase/ribbar/workctrl.cxx | 20 | ||||
-rw-r--r-- | vcl/source/window/menu.cxx | 7 |
11 files changed, 6 insertions, 67 deletions
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx index fc2719c15c77..5846d9ea4f65 100644 --- a/cui/source/tabpages/numpages.cxx +++ b/cui/source/tabpages/numpages.cxx @@ -1188,10 +1188,6 @@ SvxNumOptionsTabPage::~SvxNumOptionsTabPage() void SvxNumOptionsTabPage::dispose() { - if (m_pBitmapMB) - { - m_pBitmapMB->GetPopupMenu()->DisposePopupMenu(m_nGalleryId); - } delete pActNum; pActNum = nullptr; delete pSaveNum; diff --git a/cui/source/tabpages/tpline.cxx b/cui/source/tabpages/tpline.cxx index 43f51a5485fd..11ffd614387d 100644 --- a/cui/source/tabpages/tpline.cxx +++ b/cui/source/tabpages/tpline.cxx @@ -227,18 +227,6 @@ SvxLineTabPage::~SvxLineTabPage() void SvxLineTabPage::dispose() { - // Symbols on a line (e.g. StarCharts), dtor new! - if (m_pSymbolMB) - { - m_pSymbolMB->GetPopupMenu()->DisposePopupMenu( MN_GALLERY ); - - if(m_pSymbolList) - { - m_pSymbolMB->GetPopupMenu()->DisposePopupMenu( MN_SYMBOLS ); - } - m_pSymbolMB = nullptr; - } - for (SvxBmpItemInfo* pInfo : m_aGrfBrushItems) { delete pInfo->pBrushItem; diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 983ab27d7a07..374a3bba72bb 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -681,7 +681,7 @@ void SbaGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rM } } -void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult) +void SbaGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) { switch (nExecutionResult) { diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx index 18e20d5b86ea..4908ab97c826 100644 --- a/dbaccess/source/ui/inc/sbagrid.hxx +++ b/dbaccess/source/ui/inc/sbagrid.hxx @@ -176,7 +176,7 @@ namespace dbaui // FmGridHeader overridables virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu) override; - virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult) override; + virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) override; private: // DragSourceHelper overridables diff --git a/include/svx/fmgridcl.hxx b/include/svx/fmgridcl.hxx index f2e114c50ce9..78ad042e4571 100644 --- a/include/svx/fmgridcl.hxx +++ b/include/svx/fmgridcl.hxx @@ -67,7 +67,7 @@ protected: virtual void PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu); /** After executing the context menu for a column this method is called. */ - virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult); + virtual void PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult); // DropTargetHelper virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) override; diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 684c2a832fe3..959d54d9f118 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -282,7 +282,6 @@ public: void SetPopupMenu( sal_uInt16 nItemId, PopupMenu* pMenu ); PopupMenu* GetPopupMenu( sal_uInt16 nItemId ) const; - void DisposePopupMenu( sal_uInt16 nItemId ); void SetAccelKey( sal_uInt16 nItemId, const vcl::KeyCode& rKeyCode ); vcl::KeyCode GetAccelKey( sal_uInt16 nItemId ) const; diff --git a/svtools/source/contnr/svimpbox.cxx b/svtools/source/contnr/svimpbox.cxx index 6cd671b9f5f6..b5355525ee6d 100644 --- a/svtools/source/contnr/svimpbox.cxx +++ b/svtools/source/contnr/svimpbox.cxx @@ -2912,20 +2912,6 @@ void SvImpLBox::PaintDDCursor( SvTreeListEntry* pInsertionPos ) pView->SetRasterOp( eOldOp ); } -// Delete all submenus of a PopupMenu, recursively -static void lcl_DeleteSubPopups(PopupMenu* pPopup) -{ - for(sal_uInt16 i = 0; i < pPopup->GetItemCount(); i++) - { - VclPtr<PopupMenu> pSubPopup = pPopup->GetPopupMenu( pPopup->GetItemId( i )); - if(pSubPopup) - { - lcl_DeleteSubPopups(pSubPopup); - pPopup->DisposePopupMenu( pPopup->GetItemId( i )); - } - } -} - void SvImpLBox::Command( const CommandEvent& rCEvt ) { CommandEventId nCommand = rCEvt.GetCommand(); @@ -3024,7 +3010,6 @@ void SvImpLBox::Command( const CommandEvent& rCEvt ) sal_uInt16 nMenuAction = pPopup->Execute( pView, aPopupPos ); if ( nMenuAction ) pView->ExecuteContextMenuAction( nMenuAction ); - lcl_DeleteSubPopups(pPopup.get()); pPopup.disposeAndClear(); } } diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 27994a36cb4a..130dd4fe6fef 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -775,14 +775,11 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone }; -void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu, sal_uInt16 nExecutionResult) +void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult) { Reference< css::container::XIndexContainer > xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns()); sal_uInt16 nPos = GetModelColumnPos(nColId); - // remove and delete the menu we inserted in PreExecuteColumnContextMenu - rMenu.DisposePopupMenu(SID_FM_CHANGECOL); - OUString aFieldType; bool bReplace = false; InspectorAction eInspectorAction = eNone; diff --git a/sw/source/uibase/inc/workctrl.hxx b/sw/source/uibase/inc/workctrl.hxx index 3133b696652d..ba259bf46db1 100644 --- a/sw/source/uibase/inc/workctrl.hxx +++ b/sw/source/uibase/inc/workctrl.hxx @@ -53,9 +53,6 @@ class SwView; class SwTbxAutoTextCtrl : public SfxToolBoxControl { - VclPtr<PopupMenu> pPopup; - - void DelPopup(); public: SFX_DECL_TOOLBOX_CONTROL(); diff --git a/sw/source/uibase/ribbar/workctrl.cxx b/sw/source/uibase/ribbar/workctrl.cxx index 32eb4c5af748..8007a5010358 100644 --- a/sw/source/uibase/ribbar/workctrl.cxx +++ b/sw/source/uibase/ribbar/workctrl.cxx @@ -67,26 +67,24 @@ SwTbxAutoTextCtrl::SwTbxAutoTextCtrl( sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx ) : - SfxToolBoxControl( nSlotId, nId, rTbx ), - pPopup(nullptr) + SfxToolBoxControl( nSlotId, nId, rTbx ) { rTbx.SetItemBits( nId, ToolBoxItemBits::DROPDOWN | rTbx.GetItemBits( nId ) ); } SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl() { - DelPopup(); } VclPtr<SfxPopupWindow> SwTbxAutoTextCtrl::CreatePopupWindow() { + ScopedVclPtrInstance<PopupMenu> pPopup; SwView* pView = ::GetActiveView(); if(pView && !pView->GetDocShell()->IsReadOnly() && !pView->GetWrtShell().HasReadonlySel() ) { Link<Menu*,bool> aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl); - pPopup = VclPtr<PopupMenu>::Create(); SwGlossaryList* pGlossaryList = ::GetGlossaryList(); const size_t nGroupCount = pGlossaryList->GetGroupCount(); for(size_t i = 1; i <= nGroupCount; ++i) @@ -123,9 +121,7 @@ VclPtr<SfxPopupWindow> SwTbxAutoTextCtrl::CreatePopupWindow() pToolBox->SetItemDown( nId, false ); } GetToolBox().EndSelection(); - DelPopup(); return nullptr; - } void SwTbxAutoTextCtrl::StateChanged( sal_uInt16, @@ -158,18 +154,6 @@ IMPL_STATIC_LINK(SwTbxAutoTextCtrl, PopupHdl, Menu*, pMenu, bool) return false; } -void SwTbxAutoTextCtrl::DelPopup() -{ - if(pPopup) - { - for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ ) - { - pPopup->DisposePopupMenu(pPopup->GetItemId(i)); - } - pPopup.disposeAndClear(); - } -} - // Navigation-Popup // determine the order of the toolbox items static sal_uInt16 aNavigationInsertIds[ NAVI_ENTRIES ] = diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index 7af1ad37496d..743d724cfc9b 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -819,13 +819,6 @@ PopupMenu* Menu::GetPopupMenu( sal_uInt16 nItemId ) const return nullptr; } -void Menu::DisposePopupMenu( sal_uInt16 nItemId ) -{ - MenuItemData* pData = pItemList->GetData( nItemId ); - if ( pData ) - pData->pSubMenu.disposeAndClear(); -} - void Menu::SetAccelKey( sal_uInt16 nItemId, const KeyCode& rKeyCode ) { size_t nPos; |