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

Takeshi Abe tabe at fixedpoint.jp
Sat May 31 06:31:32 PDT 2014


 basctl/source/basicide/macrodlg.cxx |    5 +++--
 basctl/source/basicide/moduldl2.cxx |   10 +++++-----
 sw/source/uibase/wrtsh/select.cxx   |   11 +++++------
 sw/source/uibase/wrtsh/wrtsh1.cxx   |    7 +++----
 sw/source/uibase/wrtsh/wrtsh2.cxx   |   11 ++++++-----
 5 files changed, 22 insertions(+), 22 deletions(-)

New commits:
commit b32ee047312a49c13a247aa57485fad128f13317
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sat May 31 22:29:14 2014 +0900

    Avoid possible memory leaks in case of exceptions
    
    Change-Id: I1988d2766d8bdeb5f8a22a5673dcff9b898dd637

diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 0802b17..d5969d1 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -48,6 +48,7 @@
 #include <com/sun/star/document/MacroExecMode.hpp>
 
 #include <map>
+#include <boost/scoped_ptr.hpp>
 
 namespace basctl
 {
@@ -765,9 +766,9 @@ IMPL_LINK( MacroChooser, ButtonHdl, Button *, pButton )
         StoreMacroDescription();
 
         EntryDescriptor aDesc = m_pBasicBox->GetEntryDescriptor(m_pBasicBox->FirstSelected());
-        OrganizeDialog* pDlg = new OrganizeDialog( this, 0, aDesc );
+        boost::scoped_ptr<OrganizeDialog> pDlg(new OrganizeDialog( this, 0, aDesc ));
         sal_uInt16 nRet = pDlg->Execute();
-        delete pDlg;
+        pDlg.reset();
 
         if ( nRet ) // not only closed
         {
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index 7c6cca8..3a22d57 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -64,6 +64,7 @@
 #include <com/sun/star/script/ModuleSizeExceededRequest.hpp>
 
 #include <cassert>
+#include <boost/scoped_ptr.hpp>
 
 namespace basctl
 {
@@ -636,7 +637,7 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton )
                 bool const bProtected = xPasswd->isLibraryPasswordProtected( aLibName );
 
                 // change password dialog
-                SvxPasswordDialog* pDlg = new SvxPasswordDialog( this, true, !bProtected );
+                boost::scoped_ptr<SvxPasswordDialog> pDlg(new SvxPasswordDialog( this, true, !bProtected ));
                 pDlg->SetCheckPasswordHdl( LINK( this, LibPage, CheckPasswordHdl ) );
 
                 if ( pDlg->Execute() == RET_OK )
@@ -653,7 +654,6 @@ IMPL_LINK( LibPage, ButtonHdl, Button *, pButton )
 
                     MarkDocumentModified( m_aCurDocument );
                 }
-                delete pDlg;
             }
         }
     }
@@ -775,7 +775,7 @@ void LibPage::InsertLib()
 
         if ( xModLibContImport.is() || xDlgLibContImport.is() )
         {
-            LibDialog* pLibDlg = 0;
+            boost::scoped_ptr<LibDialog> pLibDlg;
 
             Reference< script::XLibraryContainer > xModLibContImp( xModLibContImport, UNO_QUERY );
             Reference< script::XLibraryContainer > xDlgLibContImp( xDlgLibContImport, UNO_QUERY );
@@ -787,7 +787,7 @@ void LibPage::InsertLib()
                 // library import dialog
                 if ( !pLibDlg )
                 {
-                    pLibDlg = new LibDialog( this );
+                    pLibDlg.reset(new LibDialog( this ));
                     pLibDlg->SetStorageName( aURLObj.getName() );
                     pLibDlg->GetLibBox().SetMode(ObjectMode::Library);
                 }
@@ -1044,7 +1044,7 @@ void LibPage::InsertLib()
                         m_pLibBox->SetCurEntry( pFirstNew );
                 }
 
-                delete pLibDlg;
+                pLibDlg.reset();
                 if ( bChanges )
                     MarkDocumentModified( m_aCurDocument );
             }
diff --git a/sw/source/uibase/wrtsh/select.cxx b/sw/source/uibase/wrtsh/select.cxx
index 76a4c2e..29fa6c4 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -39,6 +39,7 @@
 #include <crsskip.hxx>
 #include <doc.hxx>
 #include <wordcountdialog.hxx>
+#include <boost/scoped_ptr.hpp>
 
 namespace com { namespace sun { namespace star { namespace util {
     struct SearchOptions;
@@ -128,8 +129,8 @@ long SwWrtShell::SelAll()
             LeaveBlockMode();
         SwMvContext aMvContext(this);
         bool bMoveTable = false;
-        SwPosition *pStartPos = 0;
-        SwPosition *pEndPos = 0;
+        boost::scoped_ptr<SwPosition> pStartPos;
+        boost::scoped_ptr<SwPosition> pEndPos;
         SwShellCrsr* pTmpCrsr = 0;
         if( !HasWholeTabSelection() )
         {
@@ -138,8 +139,8 @@ long SwWrtShell::SelAll()
             pTmpCrsr = getShellCrsr( false );
             if( pTmpCrsr )
             {
-                pStartPos = new SwPosition( *pTmpCrsr->GetPoint() );
-                pEndPos = new SwPosition( *pTmpCrsr->GetMark() );
+                pStartPos.reset(new SwPosition( *pTmpCrsr->GetPoint() ));
+                pEndPos.reset(new SwPosition( *pTmpCrsr->GetMark() ));
             }
             Push();
             bool bIsFullSel = !MoveSection( fnSectionCurr, fnSectionStart);
@@ -187,8 +188,6 @@ long SwWrtShell::SelAll()
                       *pEndPos == *pTmpCrsr->GetPoint() ) ) && !bStartsWithTable)
                     SwCrsrShell::SttEndDoc(false);
             }
-            delete pStartPos;
-            delete pEndPos;
         }
     }
     EndSelect();
diff --git a/sw/source/uibase/wrtsh/wrtsh1.cxx b/sw/source/uibase/wrtsh/wrtsh1.cxx
index b1893be..dbd8c05 100644
--- a/sw/source/uibase/wrtsh/wrtsh1.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh1.cxx
@@ -102,6 +102,7 @@
 
 #include "PostItMgr.hxx"
 #include <sfx2/msgpool.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace sw::mark;
 using namespace com::sun::star;
@@ -371,8 +372,8 @@ void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName
                     OString aCmd(".uno:");
                     aCmd += pSlot->GetUnoName();
                     SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-                    SfxAbstractInsertObjectDialog* pDlg =
-                            pFact->CreateInsertObjectDialog( GetWin(), OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList );
+                    boost::scoped_ptr<SfxAbstractInsertObjectDialog> pDlg(
+                            pFact->CreateInsertObjectDialog( GetWin(), OStringToOUString( aCmd, RTL_TEXTENCODING_UTF8 ), xStor, &aServerList ));
                     if ( pDlg )
                     {
                         pDlg->Execute();
@@ -383,8 +384,6 @@ void SwWrtShell::InsertObject( const svt::EmbeddedObjectRef& xRef, SvGlobalName
                                      xIconMetaFile.is() ? embed::Aspects::MSOLE_ICON : embed::Aspects::MSOLE_CONTENT );
                         if ( xIconMetaFile.is() )
                             xObj.SetGraphicStream( xIconMetaFile, aIconMediaType );
-
-                        DELETEZ( pDlg );
                     }
 
                     break;
diff --git a/sw/source/uibase/wrtsh/wrtsh2.cxx b/sw/source/uibase/wrtsh/wrtsh2.cxx
index ae1d190..e0cf20b 100644
--- a/sw/source/uibase/wrtsh/wrtsh2.cxx
+++ b/sw/source/uibase/wrtsh/wrtsh2.cxx
@@ -63,6 +63,7 @@
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 
 #include <xmloff/odffields.hxx>
+#include <boost/scoped_ptr.hpp>
 
 void SwWrtShell::Insert(SwField &rFld)
 {
@@ -192,13 +193,13 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
 
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     OSL_ENSURE(pFact, "Dialogdiet fail!");
-    AbstractFldInputDlg* pDlg = pFact->CreateFldInputDlg(pParentWin, *this, pFld, bNextButton);
+    boost::scoped_ptr<AbstractFldInputDlg> pDlg(pFact->CreateFldInputDlg(pParentWin, *this, pFld, bNextButton));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if(pWindowState && !pWindowState->isEmpty())
         pDlg->SetWindowState(*pWindowState);
 
     // Register for possible input field deletion while dialog is open
-    FieldDeletionModify aModify(pDlg);
+    FieldDeletionModify aModify(pDlg.get());
     GetDoc()->GetUnoCallBack()->Add(&aModify);
 
     bool bRet = RET_CANCEL == pDlg->Execute();
@@ -209,7 +210,7 @@ bool SwWrtShell::StartInputFldDlg( SwField* pFld, bool bNextButton,
     if(pWindowState)
         *pWindowState = pDlg->GetWindowState();
 
-    delete pDlg;
+    pDlg.reset();
     GetWin()->Update();
     return bRet;
 }
@@ -219,14 +220,14 @@ bool SwWrtShell::StartDropDownFldDlg(SwField* pFld, bool bNextButton, OString* p
     SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
 
-    AbstractDropDownFieldDialog* pDlg = pFact->CreateDropDownFieldDialog(NULL, *this, pFld, bNextButton);
+    boost::scoped_ptr<AbstractDropDownFieldDialog> pDlg(pFact->CreateDropDownFieldDialog(NULL, *this, pFld, bNextButton));
     OSL_ENSURE(pDlg, "Dialogdiet fail!");
     if(pWindowState && !pWindowState->isEmpty())
         pDlg->SetWindowState(*pWindowState);
     sal_uInt16 nRet = pDlg->Execute();
     if(pWindowState)
         *pWindowState = pDlg->GetWindowState();
-    delete pDlg;
+    pDlg.reset();
     bool bRet = RET_CANCEL == nRet;
     GetWin()->Update();
     if(RET_YES == nRet)


More information about the Libreoffice-commits mailing list