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 /sd/source/ui | |
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 'sd/source/ui')
-rw-r--r-- | sd/source/ui/animations/CustomAnimationDialog.cxx | 26 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationList.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/animations/CustomAnimationList.hxx | 2 | ||||
-rw-r--r-- | sd/source/ui/annotations/annotationmanager.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/app/tmplctrl.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/dlg/navigatr.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/sidebar/LayoutMenu.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/sidebar/MasterPagesSelector.cxx | 2 | ||||
-rw-r--r-- | sd/source/ui/slideshow/slideshowimpl.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/view/drviews4.cxx | 8 |
10 files changed, 31 insertions, 34 deletions
diff --git a/sd/source/ui/animations/CustomAnimationDialog.cxx b/sd/source/ui/animations/CustomAnimationDialog.cxx index 21f61153feb7..434ef3867551 100644 --- a/sd/source/ui/animations/CustomAnimationDialog.cxx +++ b/sd/source/ui/animations/CustomAnimationDialog.cxx @@ -352,9 +352,9 @@ public: void SetMenuSelectHdl( const Link<MenuButton *, void>& rLink ) { mpDropdownButton->SetSelectHdl( rLink ); } private: - VclPtr<Edit> mpSubControl; + VclPtr<Edit> mpSubControl; VclPtr<MenuButton> mpDropdownButton; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; }; DropdownMenuBox::DropdownMenuBox( vcl::Window* pParent, Edit* pSubControl, PopupMenu* pMenu ) @@ -380,7 +380,7 @@ void DropdownMenuBox::dispose() { SetSubEdit(nullptr); mpDropdownButton.disposeAndClear(); - delete mpMenu; + mpMenu.disposeAndClear(); mpSubControl.disposeAndClear(); Edit::dispose(); } @@ -436,7 +436,7 @@ public: private: DECL_LINK_TYPED( EditModifyHdl, Edit&, void ); VclPtr<DropdownMenuBox> mpControl; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; VclPtr<MetricField> mpMetric; Link<LinkParamNone*,void> maModifyHdl; }; @@ -449,7 +449,7 @@ CharHeightPropertyBox::CharHeightPropertyBox( sal_Int32 nControlType, vcl::Windo mpMetric->SetMin( 0 ); mpMetric->SetMax( 1000 ); - mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) ); + mpMenu = VclPtr<PopupMenu>::Create(SdResId( RID_CUSTOMANIMATION_FONTSIZE_POPUP ) ); mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, CharHeightPropertyBox, implMenuSelectHdl )); mpControl->SetModifyHdl( LINK( this, CharHeightPropertyBox, EditModifyHdl ) ); @@ -521,7 +521,7 @@ public: private: VclPtr<DropdownMenuBox> mpControl; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; VclPtr<MetricField> mpMetric; Link<LinkParamNone*,void> maModifyHdl; }; @@ -535,7 +535,7 @@ TransparencyPropertyBox::TransparencyPropertyBox( sal_Int32 nControlType, vcl::W mpMetric->SetMin( 0 ); mpMetric->SetMax( 100 ); - mpMenu = new PopupMenu(); + mpMenu = VclPtr<PopupMenu>::Create(); for( sal_Int32 i = 25; i < 101; i += 25 ) { OUString aStr(unicode::formatPercent(i, @@ -621,7 +621,7 @@ public: private: VclPtr<DropdownMenuBox> mpControl; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; VclPtr<MetricField> mpMetric; Link<LinkParamNone*,void> maModifyHdl; }; @@ -636,7 +636,7 @@ RotationPropertyBox::RotationPropertyBox( sal_Int32 nControlType, vcl::Window* p mpMetric->SetMin( -10000 ); mpMetric->SetMax( 10000 ); - mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) ); + mpMenu = VclPtr<PopupMenu>::Create(SdResId( RID_CUSTOMANIMATION_ROTATION_POPUP ) ); mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, RotationPropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_ROTATIONPROPERTYBOX ); @@ -742,7 +742,7 @@ public: private: VclPtr<DropdownMenuBox> mpControl; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; VclPtr<MetricField> mpMetric; Link<LinkParamNone*,void> maModifyHdl; int mnDirection; @@ -757,7 +757,7 @@ ScalePropertyBox::ScalePropertyBox( sal_Int32 nControlType, vcl::Window* pParent mpMetric->SetMin( 0 ); mpMetric->SetMax( 10000 ); - mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) ); + mpMenu = VclPtr<PopupMenu>::Create(SdResId( RID_CUSTOMANIMATION_SCALE_POPUP ) ); mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpMetric, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, ScalePropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_SCALEPROPERTYBOX ); @@ -900,7 +900,7 @@ public: private: VclPtr<DropdownMenuBox> mpControl; - PopupMenu* mpMenu; + VclPtr<PopupMenu> mpMenu; VclPtr<Edit> mpEdit; Link<LinkParamNone*,void> maModifyHdl; @@ -916,7 +916,7 @@ FontStylePropertyBox::FontStylePropertyBox( sal_Int32 nControlType, vcl::Window* mpEdit.set( VclPtr<Edit>::Create( pParent, WB_TABSTOP|WB_IGNORETAB|WB_NOBORDER|WB_READONLY) ); mpEdit->SetText( SD_RESSTR(STR_CUSTOMANIMATION_SAMPLE) ); - mpMenu = new PopupMenu(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) ); + mpMenu = VclPtr<PopupMenu>::Create(SdResId( RID_CUSTOMANIMATION_FONTSTYLE_POPUP ) ); mpControl = VclPtr<DropdownMenuBox>::Create( pParent, mpEdit, mpMenu ); mpControl->SetMenuSelectHdl( LINK( this, FontStylePropertyBox, implMenuSelectHdl )); mpControl->SetHelpId( HID_SD_CUSTOMANIMATIONPANE_FONTSTYLEPROPERTYBOX ); diff --git a/sd/source/ui/animations/CustomAnimationList.cxx b/sd/source/ui/animations/CustomAnimationList.cxx index e6a63faf53a8..b5875ddacbdd 100644 --- a/sd/source/ui/animations/CustomAnimationList.cxx +++ b/sd/source/ui/animations/CustomAnimationList.cxx @@ -906,10 +906,9 @@ bool CustomAnimationList::DoubleClickHdl() return false; } -std::unique_ptr<PopupMenu> CustomAnimationList::CreateContextMenu() +VclPtr<PopupMenu> CustomAnimationList::CreateContextMenu() { - std::unique_ptr<PopupMenu> pMenu( - new PopupMenu(SdResId( RID_EFFECT_CONTEXTMENU ))); + VclPtrInstance<PopupMenu> pMenu(SdResId( RID_EFFECT_CONTEXTMENU )); sal_Int16 nNodeType = -1; sal_Int16 nEntries = 0; diff --git a/sd/source/ui/animations/CustomAnimationList.hxx b/sd/source/ui/animations/CustomAnimationList.hxx index dcbbf6b42217..260668b5a364 100644 --- a/sd/source/ui/animations/CustomAnimationList.hxx +++ b/sd/source/ui/animations/CustomAnimationList.hxx @@ -76,7 +76,7 @@ public: virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) override; - virtual std::unique_ptr<PopupMenu> CreateContextMenu() override; + virtual VclPtr<PopupMenu> CreateContextMenu() override; virtual void ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) override; virtual void KeyInput( const KeyEvent& rKEvt ) override; diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 03f492521b5b..a8faea0ece7c 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -915,7 +915,7 @@ void AnnotationManagerImpl::ExecuteAnnotationContextMenu( const Reference< XAnno if( bReadOnly && !pAnnotationWindow ) return; - std::unique_ptr< PopupMenu > pMenu( new PopupMenu( SdResId( pAnnotationWindow ? RID_ANNOTATION_CONTEXTMENU : RID_ANNOTATION_TAG_CONTEXTMENU ) ) ); + ScopedVclPtrInstance<PopupMenu> pMenu( SdResId( pAnnotationWindow ? RID_ANNOTATION_CONTEXTMENU : RID_ANNOTATION_TAG_CONTEXTMENU ) ); SvtUserOptions aUserOptions; OUString sCurrentAuthor( aUserOptions.GetFullName() ); diff --git a/sd/source/ui/app/tmplctrl.cxx b/sd/source/ui/app/tmplctrl.cxx index 78066ac0d657..c44eb1b69a83 100644 --- a/sd/source/ui/app/tmplctrl.cxx +++ b/sd/source/ui/app/tmplctrl.cxx @@ -104,7 +104,7 @@ void SdTemplateControl::Command( const CommandEvent& rCEvt ) if( !pDoc ) return; - SdTemplatePopup_Impl aPop; + ScopedVclPtrInstance<SdTemplatePopup_Impl> aPop; { const sal_uInt16 nMasterCount = pDoc->GetMasterSdPageCount(PK_STANDARD); @@ -113,11 +113,11 @@ void SdTemplateControl::Command( const CommandEvent& rCEvt ) { SdPage* pMaster = pDoc->GetMasterSdPage(nPage, PK_STANDARD); if( pMaster ) - aPop.InsertItem( ++nCount, pMaster->GetName() ); + aPop->InsertItem( ++nCount, pMaster->GetName() ); } - aPop.Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); + aPop->Execute( &GetStatusBar(), rCEvt.GetMousePosPixel()); - sal_uInt16 nCurrId = aPop.GetCurId()-1; + sal_uInt16 nCurrId = aPop->GetCurId()-1; if( nCurrId < nMasterCount ) { SdPage* pMaster = pDoc->GetMasterSdPage(nCurrId, PK_STANDARD); diff --git a/sd/source/ui/dlg/navigatr.cxx b/sd/source/ui/dlg/navigatr.cxx index e6b5e52f677c..548015494ec6 100644 --- a/sd/source/ui/dlg/navigatr.cxx +++ b/sd/source/ui/dlg/navigatr.cxx @@ -294,7 +294,7 @@ IMPL_LINK_TYPED( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox, void ) case TBI_DRAGTYPE: { // Popup menu is created depending if the document is saved or not - PopupMenu *pMenu = new PopupMenu; + ScopedVclPtrInstance<PopupMenu> pMenu; static const char* aHIDs[] = { @@ -331,13 +331,12 @@ IMPL_LINK_TYPED( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox, void ) pMenu->Execute( this, maToolbox->GetItemRect( nId ), PopupMenuFlags::ExecuteDown ); pBox->EndSelection(); - delete pMenu; } break; case TBI_SHAPE_FILTER: { - PopupMenu *pMenu = new PopupMenu; + ScopedVclPtrInstance<PopupMenu> pMenu; pMenu->InsertItem( nShowNamedShapesFilter, @@ -354,7 +353,6 @@ IMPL_LINK_TYPED( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox, void ) pMenu->Execute( this, maToolbox->GetItemRect( nId ), PopupMenuFlags::ExecuteDown ); pBox->EndSelection(); - delete pMenu; } break; } diff --git a/sd/source/ui/sidebar/LayoutMenu.cxx b/sd/source/ui/sidebar/LayoutMenu.cxx index f9ba5cf6caba..df4767b34813 100644 --- a/sd/source/ui/sidebar/LayoutMenu.cxx +++ b/sd/source/ui/sidebar/LayoutMenu.cxx @@ -611,7 +611,7 @@ void LayoutMenu::Command (const CommandEvent& rEvent) } // Setup the menu. - std::shared_ptr<PopupMenu> pMenu (new PopupMenu(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP))); + ScopedVclPtrInstance<PopupMenu> pMenu(SdResId(RID_TASKPANE_LAYOUTMENU_POPUP)); FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); if (pMenuWindow != nullptr) pMenuWindow->SetPopupModeFlags( diff --git a/sd/source/ui/sidebar/MasterPagesSelector.cxx b/sd/source/ui/sidebar/MasterPagesSelector.cxx index 88491e0be134..f04d11361cff 100644 --- a/sd/source/ui/sidebar/MasterPagesSelector.cxx +++ b/sd/source/ui/sidebar/MasterPagesSelector.cxx @@ -221,7 +221,7 @@ void MasterPagesSelector::Command (const CommandEvent& rEvent) } // Setup the menu. - std::unique_ptr<PopupMenu> pMenu (new PopupMenu(GetContextMenuResId())); + ScopedVclPtrInstance<PopupMenu> pMenu(GetContextMenuResId()); FloatingWindow* pMenuWindow = dynamic_cast<FloatingWindow*>(pMenu->GetWindow()); if (pMenuWindow != nullptr) pMenuWindow->SetPopupModeFlags( diff --git a/sd/source/ui/slideshow/slideshowimpl.cxx b/sd/source/ui/slideshow/slideshowimpl.cxx index 2b031ea59b95..ade2ef6f918a 100644 --- a/sd/source/ui/slideshow/slideshowimpl.cxx +++ b/sd/source/ui/slideshow/slideshowimpl.cxx @@ -1985,7 +1985,7 @@ IMPL_LINK_NOARG_TYPED(SlideshowImpl, ContextMenuHdl, void*, void) if( !mbWasPaused ) pause(); - PopupMenu* pMenu = new PopupMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) ); + VclPtrInstance<PopupMenu> pMenu( SdResId( RID_SLIDESHOW_CONTEXTMENU ) ); // Adding button to display if in Pen mode pMenu->CheckItem( CM_PEN_MODE, mbUsePen); @@ -2098,7 +2098,7 @@ IMPL_LINK_NOARG_TYPED(SlideshowImpl, ContextMenuHdl, void*, void) pMenu->SetSelectHdl( LINK( this, SlideshowImpl, ContextMenuSelectHdl ) ); pMenu->Execute( mpShowWindow, maPopupMousePos ); - delete pMenu; + pMenu.disposeAndClear(); if( mxView.is() ) mxView->ignoreNextMouseReleased(); diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 53963102144b..fc2360803384 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -556,15 +556,15 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) //fdo#44998 if the outliner has captured the mouse events release the lock //so the SdFieldPopup can get them pOLV->ReleaseMouse(); - SdFieldPopup aFieldPopup( pFldItem->GetField(), eLanguage ); + ScopedVclPtrInstance<SdFieldPopup> aFieldPopup( pFldItem->GetField(), eLanguage ); if ( rCEvt.IsMouseEvent() ) aMPos = rCEvt.GetMousePosPixel(); else aMPos = Point( 20, 20 ); - aFieldPopup.Execute( pWin, aMPos ); + aFieldPopup->Execute( pWin, aMPos ); - std::unique_ptr<SvxFieldData> pField(aFieldPopup.GetField()); + std::unique_ptr<SvxFieldData> pField(aFieldPopup->GetField()); if( pField ) { SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); @@ -876,7 +876,7 @@ void DrawViewShell::ShowSnapLineContextMenu ( const Point& rMouseLocation) { const SdrHelpLine& rHelpLine (rPageView.GetHelpLines()[nSnapLineIndex]); - std::unique_ptr<PopupMenu> pMenu (new PopupMenu ()); + ScopedVclPtrInstance<PopupMenu> pMenu; if (rHelpLine.GetKind() == SDRHELPLINE_POINT) { |