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/fmcomp/fmgridcl.cxx | |
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/fmcomp/fmgridcl.cxx')
-rw-r--r-- | svx/source/fmcomp/fmgridcl.cxx | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/svx/source/fmcomp/fmgridcl.cxx b/svx/source/fmcomp/fmgridcl.cxx index 55c1b3acfa46..9a1fa116638e 100644 --- a/svx/source/fmcomp/fmgridcl.cxx +++ b/svx/source/fmcomp/fmgridcl.cxx @@ -496,12 +496,12 @@ IMPL_LINK_NOARG_TYPED( FmGridHeader, OnAsyncExecuteDrop, void*, void ) { ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) ); - PopupMenu aInsertMenu(SVX_RES(RID_SVXMNU_COLS)); - PopupMenu aTypeMenu; - PopupMenu* pMenu = aInsertMenu.GetPopupMenu(SID_FM_INSERTCOL); + ScopedVclPtrInstance<PopupMenu> aInsertMenu(SVX_RES(RID_SVXMNU_COLS)); + ScopedVclPtrInstance<PopupMenu> aTypeMenu; + PopupMenu* pMenu = aInsertMenu->GetPopupMenu(SID_FM_INSERTCOL); for (std::vector<sal_uInt16>::const_iterator iter = aPossibleTypes.begin(); iter != aPossibleTypes.end(); ++iter) - SetMenuItem(aImageList, *iter, pMenu, aTypeMenu, true, 0); - nPreferredType = aTypeMenu.Execute(this, m_pImpl->aDropPosPixel); + SetMenuItem(aImageList, *iter, pMenu, *aTypeMenu.get(), true, 0); + nPreferredType = aTypeMenu->Execute(this, m_pImpl->aDropPosPixel); } bDateNTimeCol = nPreferredType == SID_FM_TWOFIELDS_DATE_N_TIME; @@ -657,7 +657,7 @@ void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMe bool bMarked = nColId && static_cast<FmGridControl*>(GetParent())->isColumnMarked(nColId); ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) ); - PopupMenu* pControlMenu = new PopupMenu; + VclPtrInstance<PopupMenu> pControlMenu; PopupMenu* pMenu = rMenu.GetPopupMenu(SID_FM_INSERTCOL); if (pMenu) @@ -782,8 +782,8 @@ void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMe sal_uInt16 nPos = GetModelColumnPos(nColId); // remove and delete the menu we inserted in PreExecuteColumnContextMenu - PopupMenu* pControlMenu = rMenu.GetPopupMenu(SID_FM_CHANGECOL); - delete pControlMenu; + VclPtr<PopupMenu> pControlMenu = rMenu.GetPopupMenu(SID_FM_CHANGECOL); + pControlMenu.disposeAndClear(); // NoelG: dodgy, this leaves a dangling pointer OUString aFieldType; bool bReplace = false; @@ -983,17 +983,17 @@ void FmGridHeader::triggerColumnContextMenu( const ::Point& _rPreferredPos ) sal_uInt16 nColId = GetItemId( _rPreferredPos ); // the menu - PopupMenu aContextMenu( SVX_RES( RID_SVXMNU_COLS ) ); + ScopedVclPtrInstance<PopupMenu> aContextMenu( SVX_RES( RID_SVXMNU_COLS ) ); // let derivees modify the menu - PreExecuteColumnContextMenu( nColId, aContextMenu ); - aContextMenu.RemoveDisabledEntries( true, true ); + PreExecuteColumnContextMenu( nColId, *aContextMenu ); + aContextMenu->RemoveDisabledEntries( true, true ); // execute the menu - sal_uInt16 nResult = aContextMenu.Execute( this, _rPreferredPos ); + sal_uInt16 nResult = aContextMenu->Execute( this, _rPreferredPos ); // let derivees handle the result - PostExecuteColumnContextMenu( nColId, aContextMenu, nResult ); + PostExecuteColumnContextMenu( nColId, *aContextMenu, nResult ); } void FmGridHeader::Command(const CommandEvent& rEvt) |