diff options
author | Takeshi Abe <tabe@fixedpoint.jp> | 2014-01-23 07:50:33 +0900 |
---|---|---|
committer | Takeshi Abe <tabe@fixedpoint.jp> | 2014-01-23 07:52:38 +0900 |
commit | 8532dbcfa88051104dd6eea73b75147874cdcf4a (patch) | |
tree | ee087520864439ac69dfb9ee8f851d452d55109e | |
parent | 10eeb38164b79762ab295d72da0f8ba4319b9f69 (diff) |
Avoid possible resource leaks in case of exception
Change-Id: I58d1b270de2fe1d8ffb1867e5c36ab5ebf332ae0
-rw-r--r-- | sw/source/core/doc/docdesc.cxx | 7 | ||||
-rw-r--r-- | sw/source/core/edit/autofmt.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/dbui/dbmgr.cxx | 5 | ||||
-rw-r--r-- | sw/source/ui/dochdl/swdtflvr.cxx | 6 | ||||
-rw-r--r-- | sw/source/ui/lingu/hyp.cxx | 8 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewsrch.cxx | 9 |
6 files changed, 21 insertions, 22 deletions
diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx index 1b0b81940e46..52b7ebcfc866 100644 --- a/sw/source/core/doc/docdesc.cxx +++ b/sw/source/core/doc/docdesc.cxx @@ -53,6 +53,8 @@ #include <pagedeschint.hxx> #include <tgrditem.hxx> +#include <boost/scoped_ptr.hpp> + using namespace com::sun::star; static void lcl_DefaultPageFmt( sal_uInt16 nPoolFmtId, @@ -653,7 +655,7 @@ void SwDoc::PrtDataChanged() OSL_ENSURE( get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE) || 0 != getPrinter( sal_False ), "PrtDataChanged will be called recursively!" ); SwRootFrm* pTmpRoot = GetCurrentLayout(); - SwWait *pWait = 0; + boost::scoped_ptr<SwWait> pWait; bool bEndAction = false; if( GetDocShell() ) @@ -668,7 +670,7 @@ void SwDoc::PrtDataChanged() pSh->GetViewOptions()->IsPrtFormat()) ) { if ( GetDocShell() ) - pWait = new SwWait( *GetDocShell(), true ); + pWait.reset(new SwWait( *GetDocShell(), true )); pTmpRoot->StartAllAction(); bEndAction = true; @@ -708,7 +710,6 @@ void SwDoc::PrtDataChanged() if ( bEndAction ) pTmpRoot->EndAllAction(); - delete pWait; } // We collect the GlobalNames of the servers at runtime, who don't want to be notified diff --git a/sw/source/core/edit/autofmt.cxx b/sw/source/core/edit/autofmt.cxx index fef903de0787..31cb24aebf63 100644 --- a/sw/source/core/edit/autofmt.cxx +++ b/sw/source/core/edit/autofmt.cxx @@ -64,6 +64,8 @@ #include <comcore.hrc> #include <numrule.hxx> +#include <boost/scoped_ptr.hpp> + using namespace ::com::sun::star; //JP 16.12.99: definition: @@ -2537,7 +2539,7 @@ SwAutoFormat::SwAutoFormat( SwEditShell* pEdShell, SvxSwAutoFmtFlags& rFlags, void SwEditShell::AutoFormat( const SvxSwAutoFmtFlags* pAFlags ) { - SwWait* pWait = 0; + boost::scoped_ptr<SwWait> pWait; SET_CURR_SHELL( this ); StartAllAction(); @@ -2548,7 +2550,7 @@ void SwEditShell::AutoFormat( const SvxSwAutoFmtFlags* pAFlags ) { aAFFlags = *pAFlags; if( !aAFFlags.bAFmtByInput ) - pWait = new SwWait( *GetDoc()->GetDocShell(), true ); + pWait.reset(new SwWait( *GetDoc()->GetDocShell(), true )); } SwPaM* pCrsr = GetCrsr(); @@ -2570,8 +2572,6 @@ void SwEditShell::AutoFormat( const SvxSwAutoFmtFlags* pAFlags ) EndUndo( UNDO_AUTOFORMAT ); EndAllAction(); - - delete pWait; } void SwEditShell::AutoFmtBySplitNode() diff --git a/sw/source/ui/dbui/dbmgr.cxx b/sw/source/ui/dbui/dbmgr.cxx index f1c4b2e9fb5c..8a2f1117b511 100644 --- a/sw/source/ui/dbui/dbmgr.cxx +++ b/sw/source/ui/dbui/dbmgr.cxx @@ -473,7 +473,7 @@ void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh ) if( pSh->HasSelection() ) pSh->DelRight(); - SwWait *pWait = 0; + boost::scoped_ptr<SwWait> pWait; { sal_uLong i = 0; @@ -481,7 +481,7 @@ void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh ) ImportDBEntry(pSh); if( 10 == ++i ) - pWait = new SwWait( *pSh->GetView().GetDocShell(), true); + pWait.reset(new SwWait( *pSh->GetView().GetDocShell(), true)); } while(ToNextMergeRecord()); } @@ -489,7 +489,6 @@ void SwNewDBMgr::ImportFromConnection( SwWrtShell* pSh ) pSh->DoGroupUndo(bGroupUndo); pSh->EndUndo(UNDO_EMPTY); pSh->EndAllAction(); - delete pWait; } } } diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx index d07f2fb02941..326b49296b96 100644 --- a/sw/source/ui/dochdl/swdtflvr.cxx +++ b/sw/source/ui/dochdl/swdtflvr.cxx @@ -835,9 +835,9 @@ int SwTransferable::PrepareForCopy( sal_Bool bIsCut ) else if ( pWrtShell->IsSelection() || pWrtShell->IsFrmSelected() || pWrtShell->IsObjSelected() ) { - SwWait *pWait = 0; + boost::scoped_ptr<SwWait> pWait; if( pWrtShell->ShouldWait() ) - pWait = new SwWait( *pWrtShell->GetView().GetDocShell(), true ); + pWait.reset(new SwWait( *pWrtShell->GetView().GetDocShell(), true )); pClpDocFac = new SwDocFac; @@ -958,8 +958,6 @@ int SwTransferable::PrepareForCopy( sal_Bool bIsCut ) PrepareOLE( aObjDesc ); AddFormat( SOT_FORMATSTR_ID_OBJECTDESCRIPTOR ); - - delete pWait; } else nRet = 0; diff --git a/sw/source/ui/lingu/hyp.cxx b/sw/source/ui/lingu/hyp.cxx index 9ae1d419596b..f43075de9572 100644 --- a/sw/source/ui/lingu/hyp.cxx +++ b/sw/source/ui/lingu/hyp.cxx @@ -36,6 +36,8 @@ #include <unomid.h> +#include <boost/scoped_ptr.hpp> + #define PSH (&pView->GetWrtShell()) using namespace ::com::sun::star; @@ -77,11 +79,11 @@ void SwHyphWrapper::SpellStart( SvxSpellArea eSpell ) sal_Bool SwHyphWrapper::SpellContinue() { // for automatic separation, make actions visible only at the end - SwWait *pWait = 0; + boost::scoped_ptr<SwWait> pWait; if( bAutomatic ) { PSH->StartAllAction(); - pWait = new SwWait( *pView->GetDocShell(), true ); + pWait.reset(new SwWait( *pView->GetDocShell(), true )); } uno::Reference< uno::XInterface > xHyphWord = bInSelection ? @@ -93,7 +95,7 @@ sal_Bool SwHyphWrapper::SpellContinue() if( bAutomatic ) { PSH->EndAllAction(); - delete pWait; + pWait.reset(); } return GetLast().is(); diff --git a/sw/source/ui/uiview/viewsrch.cxx b/sw/source/ui/uiview/viewsrch.cxx index fb564fd495a5..138a54866432 100644 --- a/sw/source/ui/uiview/viewsrch.cxx +++ b/sw/source/ui/uiview/viewsrch.cxx @@ -485,7 +485,7 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi) if (!m_pSrchItem->GetSelection()) m_pWrtShell->KillSelection(0, false); - SwWait *pWait = new SwWait( *GetDocShell(), true ); + boost::scoped_ptr<SwWait> pWait(new SwWait( *GetDocShell(), true )); if( FUNC_Search( aOpts ) ) { m_bFound = sal_True; @@ -496,10 +496,9 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi) } m_pWrtShell->Pop(); m_pWrtShell->EndAllAction(); - delete pWait; return sal_True; } - delete pWait, pWait = 0; + pWait.reset(); // Search in the specialized areas when no search is present in selections. // When searching selections will already searched in these special areas. @@ -561,7 +560,7 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi) } m_pWrtShell->StartAllAction(); m_pWrtShell->Pop(sal_False); - pWait = new SwWait( *GetDocShell(), true ); + pWait.reset(new SwWait( *GetDocShell(), true )); bool bSrchBkwrd = DOCPOS_START == aOpts.eEnd; @@ -579,7 +578,7 @@ sal_Bool SwView::SearchAndWrap(sal_Bool bApi) m_bFound = 0 != FUNC_Search( aOpts ); m_pWrtShell->EndAllAction(); - delete pWait; + pWait.reset(); if ( m_bFound ) return m_bFound; if(!bApi) |