Kaydet (Commit) 1c9ba8a8 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible memory leaks in case of exceptions

Change-Id: Idb8f0df3848416d96299ebc47ac5bd53d766e52c
üst dc24203e
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#include "unmovss.hxx" #include "unmovss.hxx"
#include "Outliner.hxx" #include "Outliner.hxx"
#include "sdabstdlg.hxx" #include "sdabstdlg.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
...@@ -321,7 +322,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) ...@@ -321,7 +322,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
mpDocSh->SetWaitCursor( false ); mpDocSh->SetWaitCursor( false );
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 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 ) if( !pDlg )
return false; return false;
...@@ -404,8 +405,6 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) ...@@ -404,8 +405,6 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
mpDoc->RemoveUnnecessaryMasterPages(); mpDoc->RemoveUnnecessaryMasterPages();
} }
delete pDlg;
return (bOK); return (bOK);
} }
...@@ -414,7 +413,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium) ...@@ -414,7 +413,7 @@ bool FuInsertFile::InsSDDinDrMode(SfxMedium* pMedium)
void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
{ {
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 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 ) if( !pDlg )
return; return;
...@@ -439,7 +438,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) ...@@ -439,7 +438,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
- the draw outliner of the drawing engine has to draw something in - the draw outliner of the drawing engine has to draw something in
between between
- the global outliner could be used in SdPage::CreatePresObj */ - 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 // set reference device
pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) ); pOutliner->SetRefDevice( SD_MOD()->GetRefDevice( *mpDocSh ) );
...@@ -542,10 +541,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium) ...@@ -542,10 +541,7 @@ void FuInsertFile::InsTextOrRTFinDrMode(SfxMedium* pMedium)
} }
} }
} }
delete pOutliner;
} }
delete pDlg;
} }
...@@ -595,7 +591,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) ...@@ -595,7 +591,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
- the draw outliner of the drawing engine has to draw something in - the draw outliner of the drawing engine has to draw something in
between between
- the global outliner could be used in SdPage::CreatePresObj */ - 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()); pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)mpDoc->GetStyleSheetPool());
// set reference device // set reference device
...@@ -631,7 +627,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) ...@@ -631,7 +627,7 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
mpDocSh->SetWaitCursor( false ); 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 ) if( pProgress )
pProgress->SetState( 0, 100 ); pProgress->SetState( 0, 100 );
...@@ -675,13 +671,10 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium) ...@@ -675,13 +671,10 @@ void FuInsertFile::InsTextOrRTFinOlMode(SfxMedium* pMedium)
pDocliner->GetUndoManager().LeaveListAction(); pDocliner->GetUndoManager().LeaveListAction();
if( pProgress ) pProgress.reset();
delete pProgress;
mpDocSh->SetWaitCursor( true ); mpDocSh->SetWaitCursor( true );
} }
delete pOutliner;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "app.hrc" #include "app.hrc"
#include <svx/svxdlg.hxx> #include <svx/svxdlg.hxx>
#include <svx/dialogs.hrc> #include <svx/dialogs.hrc>
#include <boost/scoped_ptr.hpp>
namespace sd { namespace sd {
...@@ -72,11 +73,11 @@ void FuLine::DoExecute( SfxRequest& rReq ) ...@@ -72,11 +73,11 @@ void FuLine::DoExecute( SfxRequest& rReq )
if( rMarkList.GetMarkCount() == 1 ) if( rMarkList.GetMarkCount() == 1 )
pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
SfxItemSet* pNewAttr = new SfxItemSet( mpDoc->GetPool() ); boost::scoped_ptr<SfxItemSet> pNewAttr(new SfxItemSet( mpDoc->GetPool() ));
mpView->GetAttributes( *pNewAttr ); mpView->GetAttributes( *pNewAttr );
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 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) ) if( pDlg && (pDlg->Execute() == RET_OK) )
{ {
mpView->SetAttributes (*(pDlg->GetOutputItemSet ())); mpView->SetAttributes (*(pDlg->GetOutputItemSet ()));
...@@ -96,9 +97,6 @@ void FuLine::DoExecute( SfxRequest& rReq ) ...@@ -96,9 +97,6 @@ void FuLine::DoExecute( SfxRequest& rReq )
0 }; 0 };
mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray ); mpViewShell->GetViewFrame()->GetBindings().Invalidate( SidArray );
delete pDlg;
delete pNewAttr;
} }
rReq.Ignore (); rReq.Ignore ();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "drawdoc.hxx" #include "drawdoc.hxx"
#include "View.hxx" #include "View.hxx"
#include "Window.hxx" #include "Window.hxx"
#include <boost/scoped_ptr.hpp>
namespace sd { namespace sd {
...@@ -114,7 +115,7 @@ void FuLineEnd::DoExecute( SfxRequest& ) ...@@ -114,7 +115,7 @@ void FuLineEnd::DoExecute( SfxRequest& )
} }
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 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 ) if( pDlg )
{ {
...@@ -144,7 +145,6 @@ void FuLineEnd::DoExecute( SfxRequest& ) ...@@ -144,7 +145,6 @@ void FuLineEnd::DoExecute( SfxRequest& )
} }
} }
} }
delete pDlg;
} }
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "drawdoc.hxx" #include "drawdoc.hxx"
#include "ViewShell.hxx" #include "ViewShell.hxx"
#include "app.hrc" #include "app.hrc"
#include <boost/scoped_ptr.hpp>
class SfxRequest; class SfxRequest;
...@@ -60,12 +61,11 @@ void FuLink::DoExecute( SfxRequest& ) ...@@ -60,12 +61,11 @@ void FuLink::DoExecute( SfxRequest& )
sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager(); sfx2::LinkManager* pLinkManager = mpDoc->GetLinkManager();
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
SfxAbstractLinksDialog* pDlg = pFact->CreateLinksDialog( mpViewShell->GetActiveWindow(), pLinkManager ); boost::scoped_ptr<SfxAbstractLinksDialog> pDlg(pFact->CreateLinksDialog( mpViewShell->GetActiveWindow(), pLinkManager ));
if ( pDlg ) if ( pDlg )
{ {
pDlg->Execute(); pDlg->Execute();
mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_MANAGE_LINKS ); mpViewShell->GetViewFrame()->GetBindings().Invalidate( SID_MANAGE_LINKS );
delete pDlg;
} }
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <svx/svditer.hxx> #include <svx/svditer.hxx>
#include <basegfx/color/bcolor.hxx> #include <basegfx/color/bcolor.hxx>
#include <boost/scoped_ptr.hpp>
namespace sd { namespace sd {
...@@ -93,7 +94,7 @@ void FuMorph::DoExecute( SfxRequest& ) ...@@ -93,7 +94,7 @@ void FuMorph::DoExecute( SfxRequest& )
SdrObject* pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false); SdrObject* pPolyObj1 = pCloneObj1->ConvertToPolyObj(false, false);
SdrObject* pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false); SdrObject* pPolyObj2 = pCloneObj2->ConvertToPolyObj(false, false);
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 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)) if(pPolyObj1 && pPolyObj2 && pDlg && (pDlg->Execute() == RET_OK))
{ {
B2DPolyPolygonList_impl aPolyPolyList; B2DPolyPolygonList_impl aPolyPolyList;
...@@ -176,7 +177,6 @@ void FuMorph::DoExecute( SfxRequest& ) ...@@ -176,7 +177,6 @@ void FuMorph::DoExecute( SfxRequest& )
} }
} }
} }
delete pDlg;
SdrObject::Free( pCloneObj1 ); SdrObject::Free( pCloneObj1 );
SdrObject::Free( pCloneObj2 ); SdrObject::Free( pCloneObj2 );
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "sdresid.hxx" #include "sdresid.hxx"
#include <tools/helpers.hxx> #include <tools/helpers.hxx>
#include <basegfx/polygon/b2dpolygon.hxx> #include <basegfx/polygon/b2dpolygon.hxx>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star; using namespace ::com::sun::star;
...@@ -448,7 +449,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) ...@@ -448,7 +449,7 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq )
aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false)); aSet.Put(SfxBoolItem(ATTR_ACTION_PLAYFULL, false));
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 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); short nResult = pDlg ? pDlg->Execute() : static_cast<short>(RET_CANCEL);
...@@ -458,8 +459,6 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq ) ...@@ -458,8 +459,6 @@ void FuObjectAnimationParameters::DoExecute( SfxRequest& rReq )
pArgs = rReq.GetArgs(); pArgs = rReq.GetArgs();
} }
delete pDlg;
if( nResult != RET_OK ) if( nResult != RET_OK )
return; return;
} }
......
...@@ -82,7 +82,7 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq ) ...@@ -82,7 +82,7 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq )
// create and execute dialog // create and execute dialog
SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 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 ) if( pDlg )
{ {
sal_uInt16 nResult = pDlg->Execute(); sal_uInt16 nResult = pDlg->Execute();
...@@ -114,13 +114,8 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq ) ...@@ -114,13 +114,8 @@ void FuOutlineBullet::DoExecute( SfxRequest& rReq )
break; break;
default: default:
{
delete pDlg;
return; return;
}
} }
delete pDlg;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment