diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-06-09 12:26:02 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-06-09 16:41:10 +0900 |
commit | cb28c59ff262cfc03dbd893dfe281ed41958b2c0 (patch) | |
tree | 084613310ce8d35f6fb7accb3833bec3407fe2b4 /sw/source/uibase/shells/drawdlg.cxx | |
parent | c892c60ae7823a735879d42df3a44b582a3ed146 (diff) |
Avoid possible memory leaks in case of exceptions
Change-Id: Id24acc128cf345a660e552f64c857906229f59c0
Diffstat (limited to 'sw/source/uibase/shells/drawdlg.cxx')
-rw-r--r-- | sw/source/uibase/shells/drawdlg.cxx | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index ce37589eb08e..79d5960b2b0f 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -33,6 +33,7 @@ #include "drawsh.hxx" #include <svx/svxdlg.hxx> #include <svx/dialogs.hrc> +#include <boost/scoped_ptr.hpp> void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) { @@ -54,7 +55,7 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); if ( pFact ) { - SfxAbstractTabDialog *pDlg = pFact->CreateTextTabDialog( NULL, &aNewAttr, pView ); + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateTextTabDialog( NULL, &aNewAttr, pView )); sal_uInt16 nResult = pDlg->Execute(); if (nResult == RET_OK) @@ -67,8 +68,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) pSh->EndAction(); } } - - delete( pDlg ); } } break; @@ -78,10 +77,10 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) bool bHasMarked = pView->AreObjectsMarked(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( NULL, + boost::scoped_ptr<AbstractSvxAreaTabDialog> pDlg(pFact->CreateSvxAreaTabDialog( NULL, &aNewAttr, pDoc, - true); + true)); if (pDlg->Execute() == RET_OK) { pSh->StartAction(); @@ -106,7 +105,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) rBnd.Update(SID_ATTR_FILL_TRANSPARENCE); rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE); } - delete pDlg; } break; @@ -121,11 +119,11 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); OSL_ENSURE(pFact, "Dialogdiet Factory fail!"); - SfxAbstractTabDialog * pDlg = pFact->CreateSvxLineTabDialog( NULL, + boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxLineTabDialog( NULL, &aNewAttr, pDoc, pObj, - bHasMarked); + bHasMarked)); OSL_ENSURE(pDlg, "Dialogdiet fail!"); if (pDlg->Execute() == RET_OK) { @@ -152,7 +150,6 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) GetView().GetViewFrame()->GetBindings().Invalidate(aInval); } - delete pDlg; } break; |