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) ...@@ -159,7 +159,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
static sal_uInt16 nBCTitleNo = 0; static sal_uInt16 nBCTitleNo = 0;
// Create DB-Manager // Create DB-Manager
SwNewDBMgr* pNewDBMgr = new SwNewDBMgr; boost::scoped_ptr<SwNewDBMgr> pNewDBMgr(new SwNewDBMgr);
// Read SwLabItem from Config // Read SwLabItem from Config
SwLabCfgItem aLabCfg(bLabel); SwLabCfgItem aLabCfg(bLabel);
...@@ -171,7 +171,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel) ...@@ -171,7 +171,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create(); SwAbstractDialogFactory* pDialogFactory = SwAbstractDialogFactory::Create();
OSL_ENSURE(pDialogFactory, "SwAbstractDialogFactory fail!"); 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!"); OSL_ENSURE(pDlg, "Dialogdiet fail!");
if ( RET_OK == pDlg->Execute() ) if ( RET_OK == pDlg->Execute() )
...@@ -277,7 +277,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel) ...@@ -277,7 +277,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
pSh->ChgPageDesc( 0, aDesc ); pSh->ChgPageDesc( 0, aDesc );
// Insert frame // Insert frame
SwFldMgr* pFldMgr = new SwFldMgr; boost::scoped_ptr<SwFldMgr> pFldMgr(new SwFldMgr);
pFldMgr->SetEvalExpFlds(sal_False); pFldMgr->SetEvalExpFlds(sal_False);
// Prepare border template // Prepare border template
...@@ -377,7 +377,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel) ...@@ -377,7 +377,7 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
pFldMgr->SetEvalExpFlds(sal_True); pFldMgr->SetEvalExpFlds(sal_True);
pFldMgr->EvalExpFlds(pSh); pFldMgr->EvalExpFlds(pSh);
delete pFldMgr; pFldMgr.reset();
if (pFirstFlyFmt) if (pFirstFlyFmt)
pSh->GotoFly(pFirstFlyFmt->GetName(), FLYCNTTYPE_ALL, sal_False); pSh->GotoFly(pFirstFlyFmt->GetName(), FLYCNTTYPE_ALL, sal_False);
...@@ -400,7 +400,6 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel) ...@@ -400,7 +400,6 @@ void SwModule::InsertLab(SfxRequest& rReq, sal_Bool bLabel)
} }
rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD)); rReq.SetReturnValue(SfxVoidItem(bLabel ? FN_LABEL : FN_BUSINESS_CARD));
} }
delete pNewDBMgr;
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1433,19 +1433,19 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL, ...@@ -1433,19 +1433,19 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
if ( bImport ) if ( bImport )
{ {
SwRead pRead = ReadXML; SwRead pRead = ReadXML;
SwReader* pReader = 0; boost::scoped_ptr<SwReader> pReader;
SwPaM* pPam = 0; boost::scoped_ptr<SwPaM> pPam;
// the SW3IO - Reader need the pam/wrtshell, because only then he // the SW3IO - Reader need the pam/wrtshell, because only then he
// insert the styles! // insert the styles!
if( bUnoCall ) if( bUnoCall )
{ {
SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 ); SwNodeIndex aIdx( pDoc->GetNodes().GetEndOfContent(), -1 );
pPam = new SwPaM( aIdx ); pPam.reset(new SwPaM( aIdx ));
pReader = new SwReader( aMed, rURL, *pPam ); pReader.reset(new SwReader( aMed, rURL, *pPam ));
} }
else else
{ {
pReader = new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ); pReader.reset(new SwReader( aMed, rURL, *pWrtShell->GetCrsr() ));
} }
pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() ); pRead->GetReaderOpt().SetTxtFmts( rOpt.IsTxtFmts() );
...@@ -1465,8 +1465,6 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL, ...@@ -1465,8 +1465,6 @@ sal_uLong SwDocShell::LoadStylesFromFile( const OUString& rURL,
nErr = pReader->Read( *pRead ); nErr = pReader->Read( *pRead );
pWrtShell->EndAllAction(); pWrtShell->EndAllAction();
} }
delete pPam;
delete pReader;
} }
return nErr; return nErr;
......
...@@ -1160,7 +1160,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, ...@@ -1160,7 +1160,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
{ {
SwWait aWait( *rSh.GetView(). SwWait aWait( *rSh.GetView().
GetDocShell(), false ); GetDocShell(), false );
SwTrnsfrActionAndUndo* pAction = 0; boost::scoped_ptr<SwTrnsfrActionAndUndo> pAction;
SwModule* pMod = SW_MOD(); SwModule* pMod = SW_MOD();
bool nRet = false; bool nRet = false;
...@@ -1214,8 +1214,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, ...@@ -1214,8 +1214,8 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
if( bDelSel ) if( bDelSel )
// #i34830# // #i34830#
pAction = new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL, pAction.reset(new SwTrnsfrActionAndUndo( &rSh, UNDO_PASTE_CLIPBOARD, NULL,
sal_True ); sal_True ));
} }
SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData ); SwTransferable *pTrans=0, *pTunneledTrans=GetSwTransferable( rData );
...@@ -1260,7 +1260,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, ...@@ -1260,7 +1260,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
{ {
if( !pAction ) 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 // in Drag&Drop MessageBoxes must not be showed
...@@ -1521,7 +1521,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData, ...@@ -1521,7 +1521,7 @@ bool SwTransferable::PasteData( TransferableDataHelper& rData,
rSh.GetView().StopShellTimer(); rSh.GetView().StopShellTimer();
} }
delete pAction; pAction.reset();
if( bCallAutoCaption ) if( bCallAutoCaption )
rSh.GetView().AutoCaption( GRAPHIC_CAP ); 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