[Libreoffice-commits] core.git: sw/source
Takeshi Abe
tabe at fixedpoint.jp
Thu Jan 23 17:58:56 PST 2014
sw/source/ui/app/applab.cxx | 9 ++++-----
sw/source/ui/app/docsh2.cxx | 12 +++++-------
sw/source/ui/dochdl/swdtflvr.cxx | 10 +++++-----
3 files changed, 14 insertions(+), 17 deletions(-)
New commits:
commit 530ddca40fc939a4d6ba6db503f0e49c10af4298
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Fri Jan 24 10:36:12 2014 +0900
Avoid resource leaks in case of exception
Change-Id: I25d012b400ce0f467e6dfa03517bfebd9c945a66
diff --git a/sw/source/ui/app/applab.cxx b/sw/source/ui/app/applab.cxx
index 735a908..829e3df 100644
--- a/sw/source/ui/app/applab.cxx
+++ b/sw/source/ui/app/applab.cxx
@@ -159,7 +159,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
static sal_uInt16 nBCTitleNo = 0;
// Create DB-Manager
- SwNewDBMgr* pNewDBMgr = new SwNewDBMgr;
+ boost::scoped_ptr<SwNewDBMgr> pNewDBMgr(new SwNewDBMgr);
// Read SwLabItem from Config
SwLabCfgItem aLabCfg(bLabel);
@@ -171,7 +171,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create();
OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!");
- boost::scoped_ptr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(0, aSet, pNewDBMgr, bLabel));
+ boost::scoped_ptr<AbstractSwLabDlg> pDlg(pDialogFactory->CreateSwLabDlg(0, aSet, pNewDBMgr.get(), bLabel));
OSL_ENSURE(pDlg, "Dialogdiet fail!");
if ( RET_OK == pDlg->Execute() )
@@ -277,7 +277,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
pSh->ChgPageDesc( 0, aDesc );
// Insert frame
- SwFldMgr* pFldMgr = new SwFldMgr;
+ boost::scoped_ptr<SwFldMgr> pFldMgr(new SwFldMgr);
pFldMgr->SetEvalExpFlds(sal_False);
// Prepare border template
@@ -377,7 +377,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
pFldMgr->SetEvalExpFlds(sal_True);
pFldMgr->EvalExpFlds(pSh);
- delete pFldMgr;
+ pFldMgr.reset();
if (pFirstFlyFmt)
pSh->GotoFly(pFirstFlyFmt->GetName(), FLYCNTTYPE_ALL, sal_False);
@@ -400,7 +400,6 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
}
rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD));
}
- delete pNewDBMgr;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/app/docsh2.cxx b/sw/source/ui/app/docsh2.cxx
index 8074f86..d328237 100644
--- a/sw/source/ui/app/docsh2.cxx
+++ b/sw/source/ui/app/docsh2.cxx
@@ -1433,19 +1433,19 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
if ( bImport )
{
SwRead pRead = ReadXML;
- SwReader* pReader = 0;
- SwPaM* pPam = 0;
+ boost::scoped_ptr<SwReader> pReader;
+ boost::scoped_ptr<SwPaM> pPam;
// the SW3IO - Reader need the pam/wrtshell, because only then he
// insert the styles!
if( bUnoCall )
{
SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 );
- pPam = new SwPaM( aIdx );
- pReader = new SwReader( aMed, rURL, *pPam );
+ pPam.reset(new SwPaM( aIdx ));
+ pReader.reset(new SwReader( aMed, rURL, *pPam ));
}
else
{
- pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() );
+ pReader.reset(new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ));
}
pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() );
@@ -1465,8 +1465,6 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
nErr = pReader->Read( *pRead );
pWrtShell->EndAllAction();
}
- delete pPam;
- delete pReader;
}
return nErr;
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 326b492..6960868 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -1160,7 +1160,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
{
SwWait aWait( *rSh.GetView().
GetDocShell(), false );
- SwTrnsfrActionAndUndo* pAction = 0;
+ boost::scoped_ptr<SwTrnsfrActionAndUndo> pAction;
SwModule* pMod = SW_MOD();
bool nRet = false;
@@ -1214,8 +1214,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
if( bDelSel )
// #i34830#
- pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
- sal_True );
+ pAction.reset(new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
+ sal_True ));
}
SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData );
@@ -1260,7 +1260,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
{
if( !pAction )
{
- pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD);
+ pAction.reset(new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD));
}
// in Drag&Drop MessageBoxes must not be showed
@@ -1521,7 +1521,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
rSh.GetView().StopShellTimer();
}
- delete pAction;
+ pAction.reset();
if( bCallAutoCaption )
rSh.GetView().AutoCaption( GRAPHIC_CAP );
More information about the Libreoffice-commits
mailing list