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

Takeshi Abe tabe at fixedpoint.jp
Sat Jun 21 18:52:16 PDT 2014


 svx/source/dialog/_bmpmask.cxx    |   26 +++++++++-----------------
 svx/source/dialog/connctrl.cxx    |   12 ++++++------
 svx/source/dialog/dialmgr.cxx     |    5 -----
 svx/source/dialog/docrecovery.cxx |   13 +++++++------
 svx/source/dialog/grfflt.cxx      |   19 +++++++------------
 svx/source/dialog/hdft.cxx        |    7 +++----
 6 files changed, 32 insertions(+), 50 deletions(-)

New commits:
commit 48fe2c03758dbfb68868a1746ccf1ed67167781b
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Jun 22 10:40:26 2014 +0900

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

diff --git a/svx/source/dialog/_bmpmask.cxx b/svx/source/dialog/_bmpmask.cxx
index 906757f..c42549d 100644
--- a/svx/source/dialog/_bmpmask.cxx
+++ b/svx/source/dialog/_bmpmask.cxx
@@ -33,7 +33,8 @@
 #include <svx/dialogs.hrc>
 #include <bmpmask.hrc>
 #include <svx/svxids.hrc>
-
+#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
 
 
 #define BMP_RESID(nId)  ResId(nId, DIALOG_MGR())
@@ -148,14 +149,12 @@ void MaskSet::KeyInput( const KeyEvent& rKEvt )
 
 void MaskSet::onEditColor()
 {
-    SvColorDialog* pColorDlg = new SvColorDialog( GetParent() );
+    boost::scoped_ptr<SvColorDialog> pColorDlg(new SvColorDialog( GetParent() ));
 
     pColorDlg->SetColor(GetItemColor(1));
 
     if( pColorDlg->Execute() )
         SetItemColor( 1, pColorDlg->GetColor() );
-
-    delete pColorDlg;
 }
 
 
@@ -775,12 +774,12 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf )
         long        nR;
         long        nG;
         long        nB;
-        long*       pMinR = new long[nCount];
-        long*       pMaxR = new long[nCount];
-        long*       pMinG = new long[nCount];
-        long*       pMaxG = new long[nCount];
-        long*       pMinB = new long[nCount];
-        long*       pMaxB = new long[nCount];
+        boost::scoped_array<long> pMinR(new long[nCount]);
+        boost::scoped_array<long> pMaxR(new long[nCount]);
+        boost::scoped_array<long> pMinG(new long[nCount]);
+        boost::scoped_array<long> pMaxG(new long[nCount]);
+        boost::scoped_array<long> pMinB(new long[nCount]);
+        boost::scoped_array<long> pMaxB(new long[nCount]);
         sal_uInt16      i;
         bool        bReplace;
 
@@ -1006,13 +1005,6 @@ GDIMetaFile SvxBmpMask::ImpMask( const GDIMetaFile& rMtf )
                 break;
             }
         }
-
-        delete[] pMinR;
-        delete[] pMaxR;
-        delete[] pMinG;
-        delete[] pMaxG;
-        delete[] pMinB;
-        delete[] pMaxB;
     }
 
     LeaveWait();
diff --git a/svx/source/dialog/connctrl.cxx b/svx/source/dialog/connctrl.cxx
index fb8f85e..bc6d869 100644
--- a/svx/source/dialog/connctrl.cxx
+++ b/svx/source/dialog/connctrl.cxx
@@ -34,6 +34,7 @@
 
 #include <vcl/builder.hxx>
 #include <vcl/settings.hxx>
+#include <boost/scoped_ptr.hpp>
 
 SvxXConnectionPreview::SvxXConnectionPreview( Window* pParent, WinBits nStyle)
     : Control(pParent, nStyle)
@@ -262,21 +263,21 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
         MapMode aMapMode = GetMapMode();
         Fraction aXFrac = aMapMode.GetScaleX();
         Fraction aYFrac = aMapMode.GetScaleY();
-        Fraction* pMultFrac;
+        boost::scoped_ptr<Fraction> pMultFrac;
 
         if( bZoomIn )
         {
             if( bCtrl )
-                pMultFrac = new Fraction( 3, 2 );
+                pMultFrac.reset(new Fraction( 3, 2 ));
             else
-                pMultFrac = new Fraction( 11, 10 );
+                pMultFrac.reset(new Fraction( 11, 10 ));
         }
         else
         {
             if( bCtrl )
-                pMultFrac = new Fraction( 2, 3 );
+                pMultFrac.reset(new Fraction( 2, 3 ));
             else
-                pMultFrac = new Fraction( 10, 11 );
+                pMultFrac.reset(new Fraction( 10, 11 ));
         }
 
         aXFrac *= *pMultFrac;
@@ -301,7 +302,6 @@ void SvxXConnectionPreview::MouseButtonDown( const MouseEvent& rMEvt )
 
             Invalidate();
         }
-        delete pMultFrac;
     }
 }
 
diff --git a/svx/source/dialog/docrecovery.cxx b/svx/source/dialog/docrecovery.cxx
index f20ab7b..0000f1d 100644
--- a/svx/source/dialog/docrecovery.cxx
+++ b/svx/source/dialog/docrecovery.cxx
@@ -58,6 +58,7 @@
 #include <unotools/localfilehelper.hxx>
 #include "svtools/treelistentry.hxx"
 #include <officecfg/Office/Recovery.hxx>
+#include <boost/scoped_ptr.hpp>
 
 namespace svx{
     namespace DocRecovery{
@@ -655,9 +656,9 @@ SaveDialog::SaveDialog(Window* pParent, RecoveryCore* pCore)
 IMPL_LINK_NOARG(SaveDialog, OKButtonHdl)
 {
     // start crash-save with progress
-    SaveProgressDialog* pProgress = new SaveProgressDialog(this, m_pCore);
+    boost::scoped_ptr<SaveProgressDialog> pProgress(new SaveProgressDialog(this, m_pCore));
     short nResult = pProgress->Execute();
-    delete pProgress;
+    pProgress.reset();
 
     // if "CANCEL" => return "CANCEL"
     // if "OK"     => "AUTOLUNCH" always !
@@ -943,14 +944,14 @@ short RecoveryDialog::execute()
                  // failed recovery documents. They must be saved to
                  // a user selected directrory.
                  short                 nRet                  = DLG_RET_UNKNOWN;
-                 BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
+                 boost::scoped_ptr<BrokenRecoveryDialog> pBrokenRecoveryDialog(new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted));
                  OUString              sSaveDir              = pBrokenRecoveryDialog->getSaveDirURL(); // get the default dir
                  if (pBrokenRecoveryDialog->isExecutionNeeded())
                  {
                      nRet = pBrokenRecoveryDialog->Execute();
                      sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
                  }
-                 delete pBrokenRecoveryDialog;
+                 pBrokenRecoveryDialog.reset();
 
                  switch(nRet)
                  {
@@ -1012,7 +1013,7 @@ short RecoveryDialog::execute()
                  // If no temp files exists or user decided to ignore it ...
                  // we have to remove all recovery/session data anyway!
                  short                 nRet                  = DLG_RET_UNKNOWN;
-                 BrokenRecoveryDialog* pBrokenRecoveryDialog = new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted);
+                 boost::scoped_ptr<BrokenRecoveryDialog> pBrokenRecoveryDialog(new BrokenRecoveryDialog(this, m_pCore, !m_bWasRecoveryStarted));
                  OUString              sSaveDir              = pBrokenRecoveryDialog->getSaveDirURL(); // get the default save location
 
                  // dialog itself checks if there is a need to copy files for this mode.
@@ -1022,7 +1023,7 @@ short RecoveryDialog::execute()
                      nRet     = pBrokenRecoveryDialog->Execute();
                      sSaveDir = pBrokenRecoveryDialog->getSaveDirURL();
                  }
-                 delete pBrokenRecoveryDialog;
+                 pBrokenRecoveryDialog.reset();
 
                  // Possible states:
                  // a) nRet == DLG_RET_UNKNOWN
diff --git a/svx/source/dialog/grfflt.cxx b/svx/source/dialog/grfflt.cxx
index 84971ba..4368ef5 100644
--- a/svx/source/dialog/grfflt.cxx
+++ b/svx/source/dialog/grfflt.cxx
@@ -28,6 +28,7 @@
 #include <svx/grfflt.hxx>
 #include <svx/dialogs.hrc>
 #include <svx/svxdlg.hxx>
+#include <boost/scoped_ptr.hpp>
 
 
 // - SvxGraphicFilter -
@@ -77,11 +78,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSmooth(pWindow, rGraphic, 0.7);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSmooth(pWindow, rGraphic, 0.7));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
@@ -166,11 +166,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterMosaic(pWindow, rGraphic, 4, 4, false);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterMosaic(pWindow, rGraphic, 4, 4, false));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
@@ -180,11 +179,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterEmboss(pWindow, rGraphic, RP_MM);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterEmboss(pWindow, rGraphic, RP_MM));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
@@ -194,11 +192,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterPoster(pWindow, rGraphic, 16);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterPoster(pWindow, rGraphic, 16));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
@@ -233,11 +230,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSepia(pWindow, rGraphic, 10);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSepia(pWindow, rGraphic, 10));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
@@ -247,11 +243,10 @@ sal_uIntPtr SvxGraphicFilter::ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObj
                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
                 if(pFact)
                 {
-                    AbstractGraphicFilterDialog* aDlg = pFact->CreateGraphicFilterSolarize(pWindow, rGraphic, 128, false);
+                    boost::scoped_ptr<AbstractGraphicFilterDialog> aDlg(pFact->CreateGraphicFilterSolarize(pWindow, rGraphic, 128, false));
                     DBG_ASSERT(aDlg, "Dialogdiet fail!");
                     if( aDlg->Execute() == RET_OK )
                         aGraphic = aDlg->GetFilteredGraphic( rGraphic, 1.0, 1.0 );
-                    delete aDlg;
                 }
             }
             break;
diff --git a/svx/source/dialog/hdft.cxx b/svx/source/dialog/hdft.cxx
index 6e8c26c..4e8b647 100644
--- a/svx/source/dialog/hdft.cxx
+++ b/svx/source/dialog/hdft.cxx
@@ -46,6 +46,7 @@
 #include <editeng/boxitem.hxx>
 
 #include <svx/svxdlg.hxx>
+#include <boost/scoped_ptr.hpp>
 // static ----------------------------------------------------------------
 
 // Word 97 incompatibility (#i19922#)
@@ -83,7 +84,7 @@ namespace svx {
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         if(pFact)
         {
-            SfxAbstractTabDialog* pDlg = pFact->CreateSvxBorderBackgroundDlg( pParent, *pBBSet, bEnableBackgroundSelector );
+            boost::scoped_ptr<SfxAbstractTabDialog> pDlg(pFact->CreateSvxBorderBackgroundDlg( pParent, *pBBSet, bEnableBackgroundSelector ));
             DBG_ASSERT(pDlg, "Dialogdiet fail!");
             if ( pDlg->Execute() == RET_OK && pDlg->GetOutputItemSet() )
             {
@@ -98,7 +99,6 @@ namespace svx {
                 }
                 bRes = true;
             }
-            delete pDlg;
         }
         return bRes;
     }
@@ -257,10 +257,9 @@ bool SvxHFPage::FillItemSet( SfxItemSet* rSet )
         aSet.Put( SfxBoolItem( nWSharedFirst,  m_pCntSharedFirstBox->IsChecked() ) );
     if(m_pDynSpacingCB->IsVisible() && SFX_WHICH_MAX > nWDynSpacing)
     {
-        SfxBoolItem* pBoolItem = (SfxBoolItem*)pPool->GetDefaultItem(nWDynSpacing).Clone();
+        boost::scoped_ptr<SfxBoolItem> pBoolItem((SfxBoolItem*)pPool->GetDefaultItem(nWDynSpacing).Clone());
         pBoolItem->SetValue(m_pDynSpacingCB->IsChecked());
         aSet.Put(*pBoolItem);
-        delete pBoolItem;
     }
 
     // Size
commit 27cd8b737522f43651ad98d91c26499321741247
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Sun Jun 22 10:37:53 2014 +0900

    Drop commented-out code
    
    Change-Id: I254e429201183b6112625fd04683d7c2aa8b867a

diff --git a/svx/source/dialog/dialmgr.cxx b/svx/source/dialog/dialmgr.cxx
index 89b50d8..bf9f976 100644
--- a/svx/source/dialog/dialmgr.cxx
+++ b/svx/source/dialog/dialmgr.cxx
@@ -17,11 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
-//#ifdef SVX_DLLIMPLEMENTATION
-//#undef SVX_DLLIMPLEMENTATION
-//#endif
-
 #include <svx/dialmgr.hxx>
 #include <svl/solar.hrc>
 #include <vcl/svapp.hxx>


More information about the Libreoffice-commits mailing list