diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-26 22:03:26 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-26 22:14:51 +0900 |
commit | ac1f7774b789c747d1aa0135762c2d0d804e69b3 (patch) | |
tree | 21d68c38d26097f588a59c602a4dd6254cb3eac0 /sd | |
parent | 231050ddcc8a286baf4e27e4858b2d7712ac22cc (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: I185e957da57f4da7dbd2b95496bcd5349fc7d039
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/MediaObjectBar.cxx | 9 | ||||
-rw-r--r-- | sd/source/ui/view/drtxtob1.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/view/drviews3.cxx | 10 | ||||
-rw-r--r-- | sd/source/ui/view/drviews4.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/view/drviews5.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/view/drviews9.cxx | 6 | ||||
-rw-r--r-- | sd/source/ui/view/drviewsa.cxx | 8 |
7 files changed, 26 insertions, 27 deletions
diff --git a/sd/source/ui/view/MediaObjectBar.cxx b/sd/source/ui/view/MediaObjectBar.cxx index c2bfb8a2d704..612faa216aa7 100644 --- a/sd/source/ui/view/MediaObjectBar.cxx +++ b/sd/source/ui/view/MediaObjectBar.cxx @@ -39,6 +39,7 @@ #include "drawview.hxx" #include "sdresid.hxx" #include "drawdoc.hxx" +#include <boost/scoped_ptr.hpp> using namespace sd; @@ -89,7 +90,7 @@ void MediaObjectBar::GetState( SfxItemSet& rSet ) { if( SID_AVMEDIA_TOOLBOX == nWhich ) { - SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() ); + boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() )); bool bDisable = true; if( 1 == pMarkList->GetMarkCount() ) @@ -108,8 +109,6 @@ void MediaObjectBar::GetState( SfxItemSet& rSet ) if( bDisable ) rSet.DisableItem( SID_AVMEDIA_TOOLBOX ); - - delete pMarkList; } nWhich = aIter.NextWhich(); @@ -130,7 +129,7 @@ void MediaObjectBar::Execute( SfxRequest& rReq ) if( pItem ) { - SdrMarkList* pMarkList = new SdrMarkList( mpView->GetMarkedObjectList() ); + boost::scoped_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() )); if( 1 == pMarkList->GetMarkCount() ) { @@ -146,8 +145,6 @@ void MediaObjectBar::Execute( SfxRequest& rReq ) rDoc.SetChanged(true); } } - - delete pMarkList; } } } diff --git a/sd/source/ui/view/drtxtob1.cxx b/sd/source/ui/view/drtxtob1.cxx index 605983c7a4d5..c51ab23c28f6 100644 --- a/sd/source/ui/view/drtxtob1.cxx +++ b/sd/source/ui/view/drtxtob1.cxx @@ -150,7 +150,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) SfxItemSet aTmpSet( pOLV->GetOutliner()->GetParaAttribs( nPara ) ); aAttr.Put( aTmpSet, false ); // sal_False= InvalidItems is not default, handle it as "holes" const SvxULSpaceItem& rItem = (const SvxULSpaceItem&) aAttr.Get( EE_PARA_ULSPACE ); - SvxULSpaceItem* pNewItem = (SvxULSpaceItem*) rItem.Clone(); + boost::scoped_ptr<SvxULSpaceItem> pNewItem((SvxULSpaceItem*) rItem.Clone()); long nUpper = pNewItem->GetUpper(); if( nSlot == SID_PARASPACE_INCREASE ) @@ -174,7 +174,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) SfxItemSet aNewAttrs( aAttr ); aNewAttrs.Put( *pNewItem ); - delete pNewItem; + pNewItem.reset(); pOLV->GetOutliner()->SetParaAttribs( nPara, aNewAttrs ); } } @@ -191,7 +191,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) { SfxItemSet aNewAttrs(*(aEditAttr.GetPool()), aEditAttr.GetRanges()); const SvxULSpaceItem& rItem = (const SvxULSpaceItem&) aEditAttr.Get( EE_PARA_ULSPACE ); - SvxULSpaceItem* pNewItem = (SvxULSpaceItem*) rItem.Clone(); + boost::scoped_ptr<SvxULSpaceItem> pNewItem((SvxULSpaceItem*) rItem.Clone()); long nUpper = pNewItem->GetUpper(); if( nSlot == SID_PARASPACE_INCREASE ) @@ -214,7 +214,7 @@ void TextObjectBar::Execute( SfxRequest &rReq ) pNewItem->SetLower( (sal_uInt16) nLower ); aNewAttrs.Put( *pNewItem ); - delete pNewItem; + pNewItem.reset(); mpView->SetAttributes( aNewAttrs ); } diff --git a/sd/source/ui/view/drviews3.cxx b/sd/source/ui/view/drviews3.cxx index 885011dca050..3b5af17c5962 100644 --- a/sd/source/ui/view/drviews3.cxx +++ b/sd/source/ui/view/drviews3.cxx @@ -83,6 +83,8 @@ #include <com/sun/star/frame/XFrame.hpp> #include <editeng/lspcitem.hxx> #include <editeng/ulspitem.hxx> +#include <boost/scoped_ptr.hpp> + using namespace ::com::sun::star::uno; using namespace ::com::sun::star::drawing::framework; using ::com::sun::star::frame::XFrame; @@ -291,11 +293,11 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) case SID_INSERT_DATE_TIME: { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - AbstractHeaderFooterDialog* pDlg = pFact ? pFact->CreateHeaderFooterDialog( (::ViewShell*)this, GetActiveWindow(), GetDoc(), mpActualPage ) : 0; + boost::scoped_ptr<AbstractHeaderFooterDialog> pDlg(pFact ? pFact->CreateHeaderFooterDialog( (::ViewShell*)this, GetActiveWindow(), GetDoc(), mpActualPage ) : 0); if( pDlg ) { pDlg->Execute(); - delete pDlg; + pDlg.reset(); GetActiveWindow()->Invalidate(); UpdatePreview( mpActualPage ); @@ -315,11 +317,11 @@ void DrawViewShell::ExecCtrl(SfxRequest& rReq) pPage = static_cast<SdPage*>(&pPage->TRG_GetMasterPage()); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - VclAbstractDialog* pDlg = pFact ? pFact->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage ) : 0; + boost::scoped_ptr<VclAbstractDialog> pDlg(pFact ? pFact->CreateMasterLayoutDialog( GetActiveWindow(), GetDoc(), pPage ) : 0); if( pDlg ) { pDlg->Execute(); - delete pDlg; + pDlg.reset(); Invalidate(); } rReq.Done (); diff --git a/sd/source/ui/view/drviews4.cxx b/sd/source/ui/view/drviews4.cxx index 8289adeba1b4..e01ed34c844e 100644 --- a/sd/source/ui/view/drviews4.cxx +++ b/sd/source/ui/view/drviews4.cxx @@ -65,6 +65,8 @@ #include <svx/svditer.hxx> #include <navigatr.hxx> +#include <boost/scoped_ptr.hpp> + namespace sd { #define PIPETTE_RANGE 0 @@ -558,7 +560,7 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) aMPos = Point( 20, 20 ); aFieldPopup.Execute( pWin, aMPos ); - SvxFieldData* pField = aFieldPopup.GetField(); + boost::scoped_ptr<SvxFieldData> pField(aFieldPopup.GetField()); if( pField ) { SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); @@ -578,8 +580,6 @@ void DrawViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin) if( !bSel ) aSel.nEndPos--; pOLV->SetSelection( aSel ); - - delete pField; } } else diff --git a/sd/source/ui/view/drviews5.cxx b/sd/source/ui/view/drviews5.cxx index 2e98ec506d2b..372a931895f9 100644 --- a/sd/source/ui/view/drviews5.cxx +++ b/sd/source/ui/view/drviews5.cxx @@ -64,6 +64,7 @@ #include "FormShellManager.hxx" #include "LayerDialogContent.hxx" #include "DrawController.hxx" +#include <boost/scoped_ptr.hpp> namespace sd { @@ -619,12 +620,11 @@ void DrawViewShell::SetActiveTabLayerIndex (int nIndex) // Tell the draw view and the tab control of the new active layer. mpDrawView->SetActiveLayer (pBar->GetPageText (pBar->GetPageId ((sal_uInt16)nIndex))); pBar->SetCurPageId (pBar->GetPageId ((sal_uInt16)nIndex)); - SdUnoDrawView* pUnoDrawView = new SdUnoDrawView ( + boost::scoped_ptr<SdUnoDrawView> pUnoDrawView(new SdUnoDrawView ( *this, - *GetView()); + *GetView())); ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XLayer> rLayer = pUnoDrawView->getActiveLayer(); GetViewShellBase().GetDrawController().fireChangeLayer( &rLayer ); - delete pUnoDrawView; } } } diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx index 1d3c7986731d..1524153407ff 100644 --- a/sd/source/ui/view/drviews9.cxx +++ b/sd/source/ui/view/drviews9.cxx @@ -59,6 +59,7 @@ #include <svx/galleryitem.hxx> #include <com/sun/star/gallery/GalleryItemType.hpp> +#include <boost/scoped_ptr.hpp> namespace sd { @@ -208,7 +209,7 @@ void DrawViewShell::AttrExec (SfxRequest &rReq) CheckLineTo (rReq); SfxBindings& rBindings = GetViewFrame()->GetBindings(); - SfxItemSet* pAttr = new SfxItemSet ( GetDoc()->GetPool() ); + boost::scoped_ptr<SfxItemSet> pAttr(new SfxItemSet ( GetDoc()->GetPool() )); GetView()->GetAttributes( *pAttr ); const SfxItemSet* pArgs = rReq.GetArgs(); @@ -733,9 +734,8 @@ void DrawViewShell::AttrExec (SfxRequest &rReq) ; } - mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr); + mpDrawView->SetAttributes (*(const SfxItemSet *) pAttr.get()); rReq.Ignore (); - delete pAttr; } /** diff --git a/sd/source/ui/view/drviewsa.cxx b/sd/source/ui/view/drviewsa.cxx index 8e1e09dd35cb..badc272ff18d 100644 --- a/sd/source/ui/view/drviewsa.cxx +++ b/sd/source/ui/view/drviewsa.cxx @@ -69,6 +69,7 @@ #include "DrawController.hxx" #include <boost/bind.hpp> +#include <boost/scoped_ptr.hpp> using namespace ::rtl; using namespace ::com::sun::star; @@ -598,13 +599,13 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) } else { - SvxZoomItem* pZoomItem; + boost::scoped_ptr<SvxZoomItem> pZoomItem; sal_uInt16 nZoom = (sal_uInt16) GetActiveWindow()->GetZoom(); if( mbZoomOnPage ) - pZoomItem = new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom ); + pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_WHOLEPAGE, nZoom )); else - pZoomItem = new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom ); + pZoomItem.reset(new SvxZoomItem( SVX_ZOOM_PERCENT, nZoom )); // constrain area sal_uInt16 nZoomValues = SVX_ZOOM_ENABLE_ALL; @@ -618,7 +619,6 @@ void DrawViewShell::GetStatusBarState(SfxItemSet& rSet) pZoomItem->SetValueSet( nZoomValues ); rSet.Put( *pZoomItem ); - delete pZoomItem; } } if( SFX_ITEM_AVAILABLE == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) ) |