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 /vcl/source/control/edit.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 'vcl/source/control/edit.cxx')
-rw-r--r-- | vcl/source/control/edit.cxx | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index dcadb57237d0..f1bb069fd4f3 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -1976,7 +1976,7 @@ void Edit::Command( const CommandEvent& rCEvt ) { if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) { - PopupMenu* pPopup = Edit::CreatePopupMenu(); + VclPtr<PopupMenu> pPopup = Edit::CreatePopupMenu(); if ( !maSelection.Len() ) { @@ -2036,7 +2036,7 @@ void Edit::Command( const CommandEvent& rCEvt ) aPos = Point( aSize.Width()/2, aSize.Height()/2 ); } sal_uInt16 n = pPopup->Execute( this, aPos ); - Edit::DeletePopupMenu( pPopup ); + pPopup.disposeAndClear(); SetSelection( aSaveSel ); switch ( n ) { @@ -2827,13 +2827,13 @@ FncGetSpecialChars Edit::GetGetSpecialCharsFunction() return pImplFncGetSpecialChars; } -PopupMenu* Edit::CreatePopupMenu() +VclPtr<PopupMenu> Edit::CreatePopupMenu() { ResMgr* pResMgr = ImplGetResMgr(); if( ! pResMgr ) - return new PopupMenu(); + return VclPtr<PopupMenu>::Create(); - PopupMenu* pPopup = new PopupMenu( ResId( SV_RESID_MENU_EDIT, *pResMgr ) ); + VclPtrInstance<PopupMenu> pPopup( ResId( SV_RESID_MENU_EDIT, *pResMgr ) ); const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); if ( rStyleSettings.GetHideDisabledMenuItems() ) pPopup->SetMenuFlags( MenuFlags::HideDisabledEntries ); @@ -2852,11 +2852,6 @@ PopupMenu* Edit::CreatePopupMenu() return pPopup; } -void Edit::DeletePopupMenu( PopupMenu* pMenu ) -{ - delete pMenu; -} - // css::datatransfer::dnd::XDragGestureListener void Edit::dragGestureRecognized( const css::datatransfer::dnd::DragGestureEvent& rDGE ) throw (css::uno::RuntimeException, std::exception) { |