diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-21 00:21:12 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-05-21 00:25:20 +0900 |
commit | 1c9ba8a81ca3b92e8fd684b4c16a06b5180ceb64 (patch) | |
tree | 22646b8c6c344d11d1ebc131a4e3fc9f4a10bb47 /sd | |
parent | dc24203e5f20dcbf2818651a8802e67338293b3c (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: Idb8f0df3848416d96299ebc47ac5bd53d766e52c
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/func/fuinsfil.cxx | 21 | ||||
-rw-r--r-- | sd/source/ui/func/fuline.cxx | 8 | ||||
-rw-r--r-- | sd/source/ui/func/fulinend.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/fulink.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/fumorph.cxx | 4 | ||||
-rw-r--r-- | sd/source/ui/func/fuoaprms.cxx | 5 | ||||
-rw-r--r-- | sd/source/ui/func/fuolbull.cxx | 7 |
7 files changed, 19 insertions, 34 deletions
diff --git a/sd/source/ui/func/fuinsfil.cxx b/sd/source/ui/func/fuinsfil.cxx index 5110cdb17fa1..3959348e78d6 100644 --- a/sd/source/ui/func/fuinsfil.cxx +++ b/sd/source/ui/func/fuinsfil.cxx @@ -63,6 +63,7 @@ #include "unmovss.hxx" #include "Outliner.hxx" #include "sdabstdlg.hxx" +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; @@ -321,7 +322,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) mpDocSh->SetWaitCursor( false ); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - AbstractSdInsertPagesObjsDlg* pDlg = pFact ? pFact->CreateSdInsertPagesObjsDlg( NULL, mpDoc, pMedium, aFile ) : 0; + boost::scoped_ptr<AbstractSdInsertPagesObjsDlg> pDlg(pFact ? pFact->CreateSdInsertPagesObjsDlg( NULL, mpDoc, pMedium, aFile ) : 0); if( !pDlg ) return false; @@ -404,8 +405,6 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) mpDoc->RemoveUnnecessaryMasterPages(); } - delete pDlg; - return (bOK); } @@ -414,7 +413,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) { SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - AbstractSdInsertPagesObjsDlg* pDlg = pFact ? pFact->CreateSdInsertPagesObjsDlg(NULL, mpDoc, NULL, aFile ) : 0; + boost::scoped_ptr<AbstractSdInsertPagesObjsDlg> pDlg(pFact ? pFact->CreateSdInsertPagesObjsDlg(NULL, mpDoc, NULL, aFile ) : 0); if( !pDlg ) return; @@ -439,7 +438,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) - the draw outliner of the drawing engine has to draw something in between - the global outliner could be used in SdPage::CreatePresObj */ - SdrOutliner* pOutliner = new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT ); + boost::scoped_ptr<SdrOutliner> pOutliner(new ::sd::Outliner( mpDoc, OUTLINERMODE_TEXTOBJECT )); // set reference device pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); @@ -542,10 +541,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) } } } - delete pOutliner; } - - delete pDlg; } @@ -595,7 +591,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) - the draw outliner of the drawing engine has to draw something in between - the global outliner could be used in SdPage::CreatePresObj */ - ::Outliner* pOutliner = new ::Outliner( &mpDoc->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT ); + boost::scoped_ptr< ::Outliner> pOutliner(new ::Outliner( &mpDoc->GetItemPool(), OUTLINERMODE_OUTLINEOBJECT )); pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)mpDoc->GetStyleSheetPool()); // set reference device @@ -631,7 +627,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) mpDocSh->SetWaitCursor( false ); - SfxProgress* pProgress = new SfxProgress( mpDocSh, SD_RESSTR(STR_CREATE_PAGES), nNewPages); + boost::scoped_ptr<SfxProgress> pProgress(new SfxProgress( mpDocSh, SD_RESSTR(STR_CREATE_PAGES), nNewPages)); if( pProgress ) pProgress->SetState( 0, 100 ); @@ -675,13 +671,10 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) pDocliner->GetUndoManager().LeaveListAction(); - if( pProgress ) - delete pProgress; + pProgress.reset(); mpDocSh->SetWaitCursor( true ); } - - delete pOutliner; } diff --git a/sd/source/ui/func/fuline.cxx b/sd/source/ui/func/fuline.cxx index ee03d31a58dd..46eafb87e0d2 100644 --- a/sd/source/ui/func/fuline.cxx +++ b/sd/source/ui/func/fuline.cxx @@ -36,6 +36,7 @@ #include "app.hrc" #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> +#include <boost/scoped_ptr.hpp> namespace sd { @@ -72,11 +73,11 @@ void FuLine::DoExecute( SfxRequest& rReq ) if( rMarkList.GetMarkCount() == 1 ) pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - SfxItemSet* pNewAttr = new SfxItemSet( mpDoc->GetPool() ); + boost::scoped_ptr<SfxItemSet> pNewAttr(new SfxItemSet( mpDoc->GetPool() )); mpView->GetAttributes( *pNewAttr ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - SfxAbstractTabDialog * pDlg = pFact ? pFact->CreateSvxLineTabDialog(NULL,pNewAttr,mpDoc,pObj,bHasMarked) : 0; + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSvxLineTabDialog(NULL,pNewAttr.get(),mpDoc,pObj,bHasMarked) : 0); if( pDlg && (pDlg->Execute() == RET_OK) ) { mpView->SetAttributes (*(pDlg->GetOutputItemSet ())); @@ -96,9 +97,6 @@ void FuLine::DoExecute( SfxRequest& rReq ) 0 }; mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray ); - - delete pDlg; - delete pNewAttr; } rReq.Ignore (); diff --git a/sd/source/ui/func/fulinend.cxx b/sd/source/ui/func/fulinend.cxx index 304d82ff947c..8d9db840ab4a 100644 --- a/sd/source/ui/func/fulinend.cxx +++ b/sd/source/ui/func/fulinend.cxx @@ -32,6 +32,7 @@ #include "drawdoc.hxx" #include "View.hxx" #include "Window.hxx" +#include <boost/scoped_ptr.hpp> namespace sd { @@ -114,7 +115,7 @@ void FuLineEnd::DoExecute( SfxRequest& ) } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - AbstractSvxNameDialog* pDlg = pFact ? pFact->CreateSvxNameDialog( NULL, aName, aDesc ) : 0; + boost::scoped_ptr<AbstractSvxNameDialog> pDlg(pFact ? pFact->CreateSvxNameDialog( NULL, aName, aDesc ) : 0); if( pDlg ) { @@ -144,7 +145,6 @@ void FuLineEnd::DoExecute( SfxRequest& ) } } } - delete pDlg; } } diff --git a/sd/source/ui/func/fulink.cxx b/sd/source/ui/func/fulink.cxx index 8ef97da0a508..a978cf466515 100644 --- a/sd/source/ui/func/fulink.cxx +++ b/sd/source/ui/func/fulink.cxx @@ -29,6 +29,7 @@ #include "drawdoc.hxx" #include "ViewShell.hxx" #include "app.hrc" +#include <boost/scoped_ptr.hpp> class SfxRequest; @@ -60,12 +61,11 @@ void FuLink::DoExecute( SfxRequest& ) sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( mpViewShell->GetActiveWindow(), pLinkManager ); + boost::scoped_ptr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog( mpViewShell->GetActiveWindow(), pLinkManager )); if ( pDlg ) { pDlg->Execute(); mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_MANAGE_LINKS ); - delete pDlg; } } diff --git a/sd/source/ui/func/fumorph.cxx b/sd/source/ui/func/fumorph.cxx index 73a1a8f49c67..c2036e25ea41 100644 --- a/sd/source/ui/func/fumorph.cxx +++ b/sd/source/ui/func/fumorph.cxx @@ -43,6 +43,7 @@ #include <svx/svditer.hxx> #include <basegfx/color/bcolor.hxx> +#include <boost/scoped_ptr.hpp> namespace sd { @@ -93,7 +94,7 @@ void FuMorph::DoExecute( SfxRequest& ) SdrObject* pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false); SdrObject* pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - AbstractMorphDlg* pDlg = pFact ? pFact->CreateMorphDlg( static_cast< ::Window*>(mpWindow), pObj1, pObj2 ) : 0; + boost::scoped_ptr<AbstractMorphDlg> pDlg(pFact ? pFact->CreateMorphDlg( static_cast< ::Window*>(mpWindow), pObj1, pObj2 ) : 0); if(pPolyObj1 && pPolyObj2 && pDlg && (pDlg->Execute() == RET_OK)) { B2DPolyPolygonList_impl aPolyPolyList; @@ -176,7 +177,6 @@ void FuMorph::DoExecute( SfxRequest& ) } } } - delete pDlg; SdrObject::Free( pCloneObj1 ); SdrObject::Free( pCloneObj2 ); diff --git a/sd/source/ui/func/fuoaprms.cxx b/sd/source/ui/func/fuoaprms.cxx index a7d087974e93..07e89e977044 100644 --- a/sd/source/ui/func/fuoaprms.cxx +++ b/sd/source/ui/func/fuoaprms.cxx @@ -44,6 +44,7 @@ #include "sdresid.hxx" #include <tools/helpers.hxx> #include <basegfx/polygon/b2dpolygon.hxx> +#include <boost/scoped_ptr.hpp> using namespace ::com::sun::star; @@ -448,7 +449,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false)); SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - SfxAbstractDialog* pDlg = pFact ? pFact->CreatSdActionDialog( NULL, &aSet, mpView ) : 0; + boost::scoped_ptr<SfxAbstractDialog> pDlg(pFact ? pFact->CreatSdActionDialog( NULL, &aSet, mpView ) : 0); short nResult = pDlg ? pDlg->Execute() : static_cast<short>(RET_CANCEL); @@ -458,8 +459,6 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) pArgs = rReq.GetArgs(); } - delete pDlg; - if( nResult != RET_OK ) return; } diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx index 870d4e24b213..9e12285687fc 100644 --- a/sd/source/ui/func/fuolbull.cxx +++ b/sd/source/ui/func/fuolbull.cxx @@ -82,7 +82,7 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq ) // create and execute dialog SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); - SfxAbstractTabDialog* pDlg = pFact ? pFact->CreateSdOutlineBulletTabDlg( NULL, &aNewAttr, mpView ) : 0; + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact ? pFact->CreateSdOutlineBulletTabDlg( NULL, &aNewAttr, mpView ) : 0); if( pDlg ) { sal_uInt16 nResult = pDlg->Execute(); @@ -114,13 +114,8 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq ) break; default: - { - delete pDlg; return; - } } - - delete pDlg; } } |