diff options
author | Noel Grandin <noel@peralex.com> | 2016-06-20 15:56:35 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-06-23 06:28:00 +0000 |
commit | aa0d0536a444fb26d9e570bd6bf6c1bdc3596cf3 (patch) | |
tree | 8b2a5207e77fa4054a37b33c25378c23a00af8ed /svx/source/mnuctrls | |
parent | b722f3d6fc72877e8caaaae7291d5d736ddc494d (diff) |
tdf#97527 - vcl: reference-count Menu
some places are marked with "dodgy"- need to check those to see
what is going on, because they are leaving dangling pointers behind
in the Menu class
Change-Id: I41d5c7c0fec2f70ce9e3ffdc48cd03d26c0a869b
Reviewed-on: https://gerrit.libreoffice.org/26516
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'svx/source/mnuctrls')
-rw-r--r-- | svx/source/mnuctrls/clipboardctl.cxx | 5 | ||||
-rw-r--r-- | svx/source/mnuctrls/smarttagmenu.cxx | 9 |
2 files changed, 8 insertions, 6 deletions
diff --git a/svx/source/mnuctrls/clipboardctl.cxx b/svx/source/mnuctrls/clipboardctl.cxx index fe6a91cf922b..35561f3eda51 100644 --- a/svx/source/mnuctrls/clipboardctl.cxx +++ b/svx/source/mnuctrls/clipboardctl.cxx @@ -68,7 +68,7 @@ VclPtr<SfxPopupWindow> SvxClipBoardControl::CreatePopupWindow() if (pPopup) pPopup->Clear(); else - pPopup = new PopupMenu; + pPopup = VclPtr<PopupMenu>::Create(); sal_uInt16 nCount = pFmtItem->Count(); for (sal_uInt16 i = 0; i < nCount; ++i) @@ -134,8 +134,7 @@ void SvxClipBoardControl::DelPopup() { if(pPopup) { - delete pPopup; - pPopup = nullptr; + pPopup.disposeAndClear(); } } diff --git a/svx/source/mnuctrls/smarttagmenu.cxx b/svx/source/mnuctrls/smarttagmenu.cxx index 16b0f02756fb..0d8e9e73e0a4 100644 --- a/svx/source/mnuctrls/smarttagmenu.cxx +++ b/svx/source/mnuctrls/smarttagmenu.cxx @@ -50,7 +50,7 @@ private: sal_uInt32 nActionID ) : m_xAction( xAction ), m_xSmartTagProperties( xSmartTagProperties ), m_nActionID( nActionID ) {} }; std::vector< InvokeAction > m_aInvokeActions; - std::vector< std::unique_ptr< PopupMenu > > m_aSubMenus; + std::vector< VclPtr< PopupMenu > > m_aSubMenus; std::unique_ptr< const SvxSmartTagItem > m_pSmartTagItem; }; @@ -61,6 +61,8 @@ SmartTagMenuController::SmartTagMenuController( const css::uno::Reference< css:: SmartTagMenuController::~SmartTagMenuController() { + for (auto& i : m_aSubMenus) + i.disposeAndClear(); } void SmartTagMenuController::statusChanged( const css::frame::FeatureStateEvent& rEvent ) @@ -151,8 +153,9 @@ void SmartTagMenuController::FillMenu() if ( 1 < rActionComponentsSequence.getLength() ) { pVCLMenu->InsertItem( nMenuId, aSmartTagCaption ); - pSubMenu = new PopupMenu; - m_aSubMenus.push_back( std::unique_ptr< PopupMenu >( pSubMenu ) ); + VclPtrInstance<PopupMenu> pMenu; + pSubMenu = pMenu; + m_aSubMenus.push_back( pMenu ); pVCLMenu->SetPopupMenu( nMenuId++, pSubMenu ); } pSubMenu->SetSelectHdl( LINK( this, SmartTagMenuController, MenuSelect ) ); |