sw/source/ui/dbui/createaddresslistdialog.cxx    |    5 +++--
 sw/source/ui/dbui/customizeaddresslistdialog.cxx |    9 +++++----
 sw/source/ui/dbui/dbinsdlg.cxx                   |    8 +++-----
 sw/source/ui/dbui/mmaddressblockpage.cxx         |    6 +++---
 sw/source/ui/dbui/mmdocselectpage.cxx            |    4 ++--
 sw/source/ui/dbui/mmoutputpage.cxx               |    7 +++----
 sw/source/ui/dbui/mmoutputtypepage.cxx           |    4 ++--
 sw/source/ui/dbui/selectdbtabledialog.cxx        |    4 ++--
 sw/source/ui/dialog/uiregionsw.cxx               |   12 +++++-------
 9 files changed, 28 insertions(+), 31 deletions(-)

New commits:
commit 67577e8f6e616efd40b1d6ca842e615a02723f04
Author: Takeshi Abe <t...@fixedpoint.jp>
Date:   Mon Jun 2 18:41:34 2014 +0900

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

diff --git a/sw/source/ui/dbui/createaddresslistdialog.cxx 
b/sw/source/ui/dbui/createaddresslistdialog.cxx
index aebd382..c194d1b 100644
--- a/sw/source/ui/dbui/createaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/createaddresslistdialog.cxx
@@ -40,6 +40,7 @@
 #include <dbui.hrc>
 #include <helpid.h>
 #include <unomid.h>
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::ui::dialogs;
@@ -517,7 +518,7 @@ IMPL_LINK_NOARG(SwCreateAddressListDialog, FindHdl_Impl)
 
 IMPL_LINK(SwCreateAddressListDialog, CustomizeHdl_Impl, PushButton*, pButton)
 {
-    SwCustomizeAddressListDialog* pDlg = new 
SwCustomizeAddressListDialog(pButton, *m_pCSVData);
+    boost::scoped_ptr<SwCustomizeAddressListDialog> pDlg(new 
SwCustomizeAddressListDialog(pButton, *m_pCSVData));
     if(RET_OK == pDlg->Execute())
     {
         delete m_pCSVData;
@@ -525,7 +526,7 @@ IMPL_LINK(SwCreateAddressListDialog, CustomizeHdl_Impl, 
PushButton*, pButton)
         m_pAddressControl->SetData(*m_pCSVData);
         
m_pAddressControl->SetCurrentDataSet(m_pAddressControl->GetCurrentDataSet());
     }
-    delete pDlg;
+    pDlg.reset();
 
     //update find dialog
     if(m_pFindDlg)
diff --git a/sw/source/ui/dbui/customizeaddresslistdialog.cxx 
b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
index e3ae204..aa6e067 100644
--- a/sw/source/ui/dbui/customizeaddresslistdialog.cxx
+++ b/sw/source/ui/dbui/customizeaddresslistdialog.cxx
@@ -24,6 +24,7 @@
 #include <vcl/msgbox.hxx>
 #include <dbui.hrc>
 #include <helpid.h>
+#include <boost/scoped_ptr.hpp>
 
 SwCustomizeAddressListDialog::SwCustomizeAddressListDialog(
         Window* pParent, const SwCSVData& rOldData)
@@ -75,11 +76,11 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, 
PushButton*, pButton)
     if(nPos == LISTBOX_ENTRY_NOTFOUND)
         nPos = 0;
 
-    SwAddRenameEntryDialog* pDlg;
+    boost::scoped_ptr<SwAddRenameEntryDialog> pDlg;
     if (bRename)
-        pDlg = new SwRenameEntryDialog(pButton, m_pNewData->aDBColumnHeaders);
+        pDlg.reset(new SwRenameEntryDialog(pButton, 
m_pNewData->aDBColumnHeaders));
     else
-        pDlg = new SwAddEntryDialog(pButton, m_pNewData->aDBColumnHeaders);
+        pDlg.reset(new SwAddEntryDialog(pButton, 
m_pNewData->aDBColumnHeaders));
     if(bRename)
     {
         OUString aTemp = m_pFieldsLB->GetEntry(nPos);
@@ -110,7 +111,7 @@ IMPL_LINK(SwCustomizeAddressListDialog, AddRenameHdl_Impl, 
PushButton*, pButton)
         m_pFieldsLB->InsertEntry(sNew, nPos);
         m_pFieldsLB->SelectEntryPos(nPos);
     }
-    delete pDlg;
+    pDlg.reset();
     UpdateButtons();
     return 0;
 }
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index 3f0204f..e61d773 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -1279,8 +1279,8 @@ void SwInsertDBColAutoPilot::DataToDoc( const 
Sequence<Any>& rSelection,
 
                     case _DB_Column::DB_COL_FIELD:
                         {
-                            SwDBField *const pFld = static_cast<SwDBField *>(
-                                pDBCol->DB_ColumnData.pField->CopyField());
+                            boost::scoped_ptr<SwDBField> 
pFld(static_cast<SwDBField *>(
+                                pDBCol->DB_ColumnData.pField->CopyField()));
                             double nValue = DBL_MAX;
 
                             Reference< XPropertySet > xColumnProps;
@@ -1311,7 +1311,6 @@ void SwInsertDBColAutoPilot::DataToDoc( const 
Sequence<Any>& rSelection,
                             pFld->SetInitialized();
 
                             rSh.Insert( *pFld );
-                            delete pFld;
                         }
                         break;
 
@@ -1655,7 +1654,7 @@ void SwInsertDBColAutoPilot::Load()
         pDataSourceProps[2] >>= nCommandType;
         if(sSource.equals(aDBData.sDataSource) && 
sCommand.equals(aDBData.sCommand))
         {
-            _DB_ColumnConfigData* pNewData = new _DB_ColumnConfigData;
+            boost::scoped_ptr<_DB_ColumnConfigData> pNewData(new 
_DB_ColumnConfigData);
             pNewData->sSource = sSource;
             pNewData->sTable = sCommand;
 
@@ -1808,7 +1807,6 @@ void SwInsertDBColAutoPilot::Load()
             // when the cursor is inside of a table, table must NEVER be 
selectable
             if( !m_pRbAsTable->IsEnabled() && m_pRbAsTable->IsChecked() )
                 m_pRbAsField->Check( true );
-            delete pNewData;
             break;
         }
     }
diff --git a/sw/source/ui/dbui/mmaddressblockpage.cxx 
b/sw/source/ui/dbui/mmaddressblockpage.cxx
index a548b28..27eddc9 100644
--- a/sw/source/ui/dbui/mmaddressblockpage.cxx
+++ b/sw/source/ui/dbui/mmaddressblockpage.cxx
@@ -164,8 +164,8 @@ IMPL_LINK_NOARG(SwMailMergeAddressBlockPage, 
AddressListHdl_Impl)
 
 IMPL_LINK(SwMailMergeAddressBlockPage, SettingsHdl_Impl, PushButton*, pButton)
 {
-    SwSelectAddressBlockDialog* pDlg =
-                new SwSelectAddressBlockDialog(pButton, 
m_pWizard->GetConfigItem());
+    boost::scoped_ptr<SwSelectAddressBlockDialog> pDlg(
+                new SwSelectAddressBlockDialog(pButton, 
m_pWizard->GetConfigItem()));
     SwMailMergeConfigItem& rConfig = m_pWizard->GetConfigItem();
     pDlg->SetAddressBlocks(rConfig.GetAddressBlocks(), 
m_pSettingsWIN->GetSelectedAddress());
     pDlg->SetSettings(rConfig.IsIncludeCountry(), rConfig.GetExcludeCountry());
@@ -183,7 +183,7 @@ IMPL_LINK(SwMailMergeAddressBlockPage, SettingsHdl_Impl, 
PushButton*, pButton)
         rConfig.SetCountrySettings(pDlg->IsIncludeCountry(), 
pDlg->GetCountry());
         InsertDataHdl_Impl(0);
     }
-    delete pDlg;
+    pDlg.reset();
     GetWizard()->UpdateRoadmap();
     GetWizard()->enableButtons(WZB_NEXT, 
GetWizard()->isStateEnabled(MM_GREETINGSPAGE));
     return 0;
diff --git a/sw/source/ui/dbui/mmdocselectpage.cxx 
b/sw/source/ui/dbui/mmdocselectpage.cxx
index b00cade..a02dc2b 100644
--- a/sw/source/ui/dbui/mmdocselectpage.cxx
+++ b/sw/source/ui/dbui/mmdocselectpage.cxx
@@ -37,6 +37,7 @@
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
 #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star::ui::dialogs;
 using namespace ::com::sun::star;
@@ -110,13 +111,12 @@ IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, 
PushButton*, pButton)
     if(bTemplate)
     {
         m_pLoadTemplateRB->Check();
-        SfxNewFileDialog* pNewFileDlg = new SfxNewFileDialog(this, 0);
+        boost::scoped_ptr<SfxNewFileDialog> pNewFileDlg(new 
SfxNewFileDialog(this, 0));
         sal_uInt16 nRet = pNewFileDlg->Execute();
         if(RET_TEMPLATE_LOAD == nRet)
             bTemplate = false;
         else if(RET_CANCEL != nRet)
             m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
-        delete pNewFileDlg;
     }
     else
         m_pLoadDocRB->Check();
diff --git a/sw/source/ui/dbui/mmoutputpage.cxx 
b/sw/source/ui/dbui/mmoutputpage.cxx
index e03f303..ec88142 100644
--- a/sw/source/ui/dbui/mmoutputpage.cxx
+++ b/sw/source/ui/dbui/mmoutputpage.cxx
@@ -70,6 +70,7 @@
 #include <statstr.hrc>
 #include <unomid.h>
 #include <comphelper/string.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace svt;
 using namespace ::com::sun::star;
@@ -493,7 +494,7 @@ IMPL_LINK(SwMailMergeOutputPage, DocumentSelectionHdl_Impl, 
RadioButton*, pButto
 
 IMPL_LINK(SwMailMergeOutputPage, CopyToHdl_Impl, PushButton*, pButton)
 {
-    SwCopyToDialog* pDlg = new SwCopyToDialog(pButton);
+    boost::scoped_ptr<SwCopyToDialog> pDlg(new SwCopyToDialog(pButton));
     pDlg->SetCC(m_sCC );
     pDlg->SetBCC(m_sBCC);
     if(RET_OK == pDlg->Execute())
@@ -501,7 +502,6 @@ IMPL_LINK(SwMailMergeOutputPage, CopyToHdl_Impl, 
PushButton*, pButton)
         m_sCC =     pDlg->GetCC() ;
         m_sBCC =    pDlg->GetBCC();
     }
-    delete pDlg;
     return 0;
 }
 
@@ -898,9 +898,8 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, 
PushButton*, pButton)
         if(RET_YES == nRet )
         {
             SfxAllItemSet aSet(pTargetView->GetPool());
-            SwMailConfigDlg* pDlg = new SwMailConfigDlg(pButton, aSet);
+            boost::scoped_ptr<SwMailConfigDlg> pDlg(new 
SwMailConfigDlg(pButton, aSet));
             nRet = pDlg->Execute();
-            delete pDlg;
         }
 
         if(nRet != RET_OK && nRet != RET_YES)
diff --git a/sw/source/ui/dbui/mmoutputtypepage.cxx 
b/sw/source/ui/dbui/mmoutputtypepage.cxx
index 4571d62..e4a7397 100644
--- a/sw/source/ui/dbui/mmoutputtypepage.cxx
+++ b/sw/source/ui/dbui/mmoutputtypepage.cxx
@@ -23,6 +23,7 @@
 #include <vcl/msgbox.hxx>
 #include <dbui.hrc>
 #include <swtypes.hxx>
+#include <boost/scoped_ptr.hpp>
 
 SwMailMergeOutputTypePage::SwMailMergeOutputTypePage(SwMailMergeWizard* 
pParent)
     : svt::OWizardPage(pParent, "MMOutputTypePage",
@@ -600,9 +601,8 @@ void SwSendMailDialog::DocumentSent( uno::Reference< 
mail::XMailMessage> xMessag
 
     if (pError)
     {
-        SwSendWarningBox_Impl* pDlg = new SwSendWarningBox_Impl(0, *pError);
+        boost::scoped_ptr<SwSendWarningBox_Impl> pDlg(new 
SwSendWarningBox_Impl(0, *pError));
         pDlg->Execute();
-        delete pDlg;
     }
 }
 
diff --git a/sw/source/ui/dbui/selectdbtabledialog.cxx 
b/sw/source/ui/dbui/selectdbtabledialog.cxx
index e1774fc..113aecf 100644
--- a/sw/source/ui/dbui/selectdbtabledialog.cxx
+++ b/sw/source/ui/dbui/selectdbtabledialog.cxx
@@ -33,6 +33,7 @@
 #include <selectdbtabledialog.hrc>
 #include <dbui.hrc>
 #include <helpid.h>
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::sdbcx;
@@ -159,9 +160,8 @@ IMPL_LINK(SwSelectDBTableDialog, PreviewHdl, PushButton*, 
pButton)
         pProperties[4].Name = "ShowTreeViewButton";
         pProperties[4].Value <<= sal_False;
 
-        SwDBTablePreviewDialog* pDlg = new SwDBTablePreviewDialog(pButton, 
aProperties);
+        boost::scoped_ptr<SwDBTablePreviewDialog> pDlg(new 
SwDBTablePreviewDialog(pButton, aProperties));
         pDlg->Execute();
-        delete pDlg;
     }
 
     return 0;
diff --git a/sw/source/ui/dialog/uiregionsw.cxx 
b/sw/source/ui/dialog/uiregionsw.cxx
index a4cfbfb..a4f4fd0 100644
--- a/sw/source/ui/dialog/uiregionsw.cxx
+++ b/sw/source/ui/dialog/uiregionsw.cxx
@@ -63,6 +63,7 @@
 #include <svx/dialogs.hrc>
 #include <svx/svxdlg.hxx>
 #include <svx/flagsdef.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 
@@ -758,7 +759,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl)
         sal_uInt16 nNewPos = rDocFmts.GetPos( pFmt );
         if( USHRT_MAX != nNewPos )
         {
-            SfxItemSet* pSet = pFmt->GetAttrSet().Clone( false );
+            boost::scoped_ptr<SfxItemSet> pSet(pFmt->GetAttrSet().Clone( false 
));
             if( pFmt->GetCol() != pRepr->GetCol() )
                 pSet->Put( pRepr->GetCol() );
 
@@ -781,8 +782,7 @@ IMPL_LINK_NOARG(SwEditRegionDlg, OkHdl)
                 pSet->Put( pRepr->GetLRSpace());
 
             rSh.UpdateSection( nNewPos, pRepr->GetSectionData(),
-                            pSet->Count() ? pSet : 0 );
-            delete pSet;
+                               pSet->Count() ? pSet.get() : 0 );
         }
         pEntry = m_pTree->Next( pEntry );
     }
@@ -1307,7 +1307,7 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, 
sfx2::FileDialogHelper *, _pFileDlg )
     OUString sFileName, sFilterName, sPassword;
     if ( _pFileDlg->GetError() == ERRCODE_NONE )
     {
-        SfxMedium* pMedium = m_pDocInserter->CreateMedium();
+        boost::scoped_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium());
         if ( pMedium )
         {
             sFileName = pMedium->GetURLObject().GetMainURL( 
INetURLObject::NO_DECODE );
@@ -1316,7 +1316,6 @@ IMPL_LINK( SwEditRegionDlg, DlgClosedHdl, 
sfx2::FileDialogHelper *, _pFileDlg )
             if ( SFX_ITEM_SET == pMedium->GetItemSet()->GetItemState( 
SID_PASSWORD, false, &pItem ) )
                 sPassword = ( (SfxStringItem*)pItem )->GetValue();
             ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
-            delete pMedium;
         }
     }
 
@@ -1774,7 +1773,7 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, 
sfx2::FileDialogHelper *, _pFil
 {
     if ( _pFileDlg->GetError() == ERRCODE_NONE )
     {
-        SfxMedium* pMedium = m_pDocInserter->CreateMedium();
+        boost::scoped_ptr<SfxMedium> pMedium(m_pDocInserter->CreateMedium());
         if ( pMedium )
         {
             m_sFileName = pMedium->GetURLObject().GetMainURL( 
INetURLObject::NO_DECODE );
@@ -1785,7 +1784,6 @@ IMPL_LINK( SwInsertSectionTabPage, DlgClosedHdl, 
sfx2::FileDialogHelper *, _pFil
             m_pFileNameED->SetText( INetURLObject::decode(
                 m_sFileName, '%', INetURLObject::DECODE_UNAMBIGUOUS, 
RTL_TEXTENCODING_UTF8 ) );
             ::lcl_ReadSections(*pMedium, *m_pSubRegionED);
-            delete pMedium;
         }
     }
     else
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to