include/svx/SmartTagCtl.hxx | 5 +++-- svx/source/mnuctrls/SmartTagCtl.cxx | 10 ++++------ 2 files changed, 7 insertions(+), 8 deletions(-)
New commits: commit 1335f3bd80682987b5c1c7d9cb548e85b31e03b4 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Sun Nov 22 23:03:35 2015 +0200 SvxSmartTagsControl: Do not leak sub menus And while on it, move other things to smart pointers as well. Change-Id: I8b234b8a9fe60e0ca82bb08e48f6b7db94cbcd4d diff --git a/include/svx/SmartTagCtl.hxx b/include/svx/SmartTagCtl.hxx index e4acd3e..81aa45f 100644 --- a/include/svx/SmartTagCtl.hxx +++ b/include/svx/SmartTagCtl.hxx @@ -44,9 +44,10 @@ namespace com { namespace sun { namespace star { namespace container { class SVX_DLLPUBLIC SvxSmartTagsControl : public SfxMenuControl { private: - PopupMenu* mpMenu; + std::unique_ptr< PopupMenu > mpMenu; + std::vector< std::unique_ptr< PopupMenu > > maSubMenus; Menu& mrParent; - const SvxSmartTagItem* mpSmartTagItem; + std::unique_ptr< const SvxSmartTagItem > mpSmartTagItem; struct InvokeAction { diff --git a/svx/source/mnuctrls/SmartTagCtl.cxx b/svx/source/mnuctrls/SmartTagCtl.cxx index 0a47bf9..ab7d1fd 100644 --- a/svx/source/mnuctrls/SmartTagCtl.cxx +++ b/svx/source/mnuctrls/SmartTagCtl.cxx @@ -45,7 +45,7 @@ SvxSmartTagsControl::SvxSmartTagsControl mrParent ( rMenu ), mpSmartTagItem( nullptr ) { - rMenu.SetPopupMenu( _nId, mpMenu ); + rMenu.SetPopupMenu( _nId, mpMenu.get() ); } @@ -93,12 +93,13 @@ void SvxSmartTagsControl::FillMenu() const OUString aSmartTagCaption = xAction->getSmartTagCaption( nSmartTagIndex, rLocale); // no sub-menus if there's only one smart tag type listed: - PopupMenu* pSbMenu = mpMenu; + PopupMenu* pSbMenu = mpMenu.get(); if ( 1 < rActionComponentsSequence.getLength() ) { mpMenu->InsertItem(nMenuId, aSmartTagCaption, MenuItemBits::NONE, OString(), nMenuPos++); pSbMenu = new PopupMenu; mpMenu->SetPopupMenu( nMenuId++, pSbMenu ); + maSubMenus.push_back( std::unique_ptr< PopupMenu >( pSbMenu ) ); } pSbMenu->SetSelectHdl( LINK( this, SvxSmartTagsControl, MenuSelect ) ); @@ -145,8 +146,7 @@ void SvxSmartTagsControl::StateChanged( sal_uInt16, SfxItemState eState, const S const SvxSmartTagItem* pSmartTagItem = dynamic_cast<const SvxSmartTagItem*>( pState ); if ( nullptr != pSmartTagItem ) { - delete mpSmartTagItem; - mpSmartTagItem = new SvxSmartTagItem( *pSmartTagItem ); + mpSmartTagItem.reset( new SvxSmartTagItem( *pSmartTagItem ) ); FillMenu(); } } @@ -192,8 +192,6 @@ IMPL_LINK_TYPED( SvxSmartTagsControl, MenuSelect, Menu *, pMen, bool ) SvxSmartTagsControl::~SvxSmartTagsControl() { - delete mpSmartTagItem; - delete mpMenu; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits