Kaydet (Commit) 530ddca4 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid resource leaks in case of exception

Change-Id: I25d012b400ce0f467e6dfa03517bfebd9c945a66
üst 2d041ee4
......@@ -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: */
......@@ -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;
......
......@@ -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 );
......
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