[Libreoffice-commits] core.git: 2 commits - sw/inc sw/source

Takeshi Abe tabe at fixedpoint.jp
Wed Jan 22 14:54:01 PST 2014


 sw/inc/docsh.hxx                 |    2 +-
 sw/source/core/doc/docdesc.cxx   |    7 ++++---
 sw/source/core/edit/autofmt.cxx  |    8 ++++----
 sw/source/ui/dbui/dbmgr.cxx      |    5 ++---
 sw/source/ui/dochdl/swdtflvr.cxx |    6 ++----
 sw/source/ui/lingu/hyp.cxx       |    8 +++++---
 sw/source/ui/uiview/viewsrch.cxx |    9 ++++-----
 7 files changed, 22 insertions(+), 23 deletions(-)

New commits:
commit 8532dbcfa88051104dd6eea73b75147874cdcf4a
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Jan 23 07:50:33 2014 +0900

    Avoid possible resource leaks in case of exception
    
    Change-Id: I58d1b270de2fe1d8ffb1867e5c36ab5ebf332ae0

diff --git a/sw/source/core/doc/docdesc.cxx b/sw/source/core/doc/docdesc.cxx
index 1b0b819..52b7ebc 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 fef903d..31cb24a 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 f1c4b2e..8a2f111 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 d07f2fb..326b492 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 9ae1d41..f43075d 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 fb564fd..138a548 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)
commit 10eeb38164b79762ab295d72da0f8ba4319b9f69
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Thu Jan 23 04:10:55 2014 +0900

    Fix the class name
    
    Change-Id: I74e523717ca78983b67aa612161e8f32aaead2d1

diff --git a/sw/inc/docsh.hxx b/sw/inc/docsh.hxx
index 4a6ec3e..308811e 100644
--- a/sw/inc/docsh.hxx
+++ b/sw/inc/docsh.hxx
@@ -264,7 +264,7 @@ public:
 
     /** Activate wait cursor for all windows of this document
     Optionally all dispatcher could be Locked
-    Usually locking should be done using the class: SwWaitObject! */
+    Usually locking should be done using the class: SwWait. */
     void EnterWait( bool bLockDispatcher );
     void LeaveWait( bool bLockDispatcher );
 


More information about the Libreoffice-commits mailing list