diff options
author | Maxim Monastirsky <momonasmon@gmail.com> | 2015-11-22 23:03:35 +0200 |
---|---|---|
committer | Maxim Monastirsky <momonasmon@gmail.com> | 2015-11-23 00:04:06 +0200 |
commit | 1335f3bd80682987b5c1c7d9cb548e85b31e03b4 (patch) | |
tree | d5ccdeea6fc8780450111bbd4b590f9c801d61f4 /svx | |
parent | fae2fa55709f359847dc0e1099d6578c840f2748 (diff) |
SvxSmartTagsControl: Do not leak sub menus
And while on it, move other things to smart pointers as well.
Change-Id: I8b234b8a9fe60e0ca82bb08e48f6b7db94cbcd4d
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/mnuctrls/SmartTagCtl.cxx | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/svx/source/mnuctrls/SmartTagCtl.cxx b/svx/source/mnuctrls/SmartTagCtl.cxx index 0a47bf94046e..ab7d1fd1a63e 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; } |