svx/source/sdr/properties/e3dsceneproperties.cxx |    6 +--
 svx/source/sdr/properties/itemsettools.cxx       |    5 +-
 svx/source/sidebar/line/LinePropertyPanel.cxx    |   43 ++++++++++-------------
 svx/source/sidebar/nbdtmg.cxx                    |    7 +--
 svx/source/svdraw/svdedtv2.cxx                   |    6 +--
 svx/source/svdraw/svdedxv.cxx                    |    7 +--
 svx/source/svdraw/svdhdl.cxx                     |   14 ++-----
 7 files changed, 37 insertions(+), 51 deletions(-)

New commits:
commit 5fdcab9412c4b4470ef01e2b8b1fd0e1e7efb295
Author: Takeshi Abe <t...@fixedpoint.jp>
Date:   Sat Jun 28 18:50:18 2014 +0900

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

diff --git a/svx/source/sdr/properties/e3dsceneproperties.cxx 
b/svx/source/sdr/properties/e3dsceneproperties.cxx
index 9339a81..4bbe3ac 100644
--- a/svx/source/sdr/properties/e3dsceneproperties.cxx
+++ b/svx/source/sdr/properties/e3dsceneproperties.cxx
@@ -23,7 +23,7 @@
 #include <svx/svddef.hxx>
 #include <svx/scene3d.hxx>
 #include <svx/svditer.hxx>
-
+#include <boost/scoped_ptr.hpp>
 
 
 namespace sdr
@@ -121,7 +121,7 @@ namespace sdr
             {
                 // Generate filtered ItemSet which contains all but the 
SDRATTR_3DSCENE items.
                 // #i50808# Leak fix, Clone produces a new instance and we get 
ownership here
-                SfxItemSet* pNewSet = rSet.Clone(true);
+                boost::scoped_ptr<SfxItemSet> pNewSet(rSet.Clone(true));
                 DBG_ASSERT(pNewSet, "E3dSceneProperties::SetMergedItemSet(): 
Could not clone ItemSet (!)");
 
                 for(sal_uInt16 b(SDRATTR_3DSCENE_FIRST); b <= 
SDRATTR_3DSCENE_LAST; b++)
@@ -142,8 +142,6 @@ namespace sdr
                         }
                     }
                 }
-
-                delete pNewSet;
             }
 
             // call parent. This will set items on local object, too.
diff --git a/svx/source/sdr/properties/itemsettools.cxx 
b/svx/source/sdr/properties/itemsettools.cxx
index 0d4a5e1..dac8ac2 100644
--- a/svx/source/sdr/properties/itemsettools.cxx
+++ b/svx/source/sdr/properties/itemsettools.cxx
@@ -24,7 +24,7 @@
 #include <svx/svdogrp.hxx>
 #include <svx/svditer.hxx>
 #include <vcl/region.hxx>
-
+#include <boost/scoped_ptr.hpp>
 
 // class to remember broadcast start positions
 
@@ -113,10 +113,9 @@ namespace sdr
                 {
                     if(pItem->HasMetrics())
                     {
-                        SfxPoolItem* pNewItem = pItem->Clone();
+                        boost::scoped_ptr<SfxPoolItem> 
pNewItem(pItem->Clone());
                         pNewItem->ScaleMetrics(nMul, nDiv);
                         rSet.Put(*pNewItem);
-                        delete pNewItem;
                     }
                 }
                 nWhich = aIter.NextWhich();
diff --git a/svx/source/sidebar/line/LinePropertyPanel.cxx 
b/svx/source/sidebar/line/LinePropertyPanel.cxx
index 241d16e..7150060 100644
--- a/svx/source/sidebar/line/LinePropertyPanel.cxx
+++ b/svx/source/sidebar/line/LinePropertyPanel.cxx
@@ -53,6 +53,7 @@
 #include <svx/sidebar/ColorControl.hxx>
 #include "LineWidthControl.hxx"
 #include <boost/bind.hpp>
+#include <boost/scoped_ptr.hpp>
 
 using namespace css;
 using namespace cssu;
@@ -736,13 +737,12 @@ IMPL_LINK(LinePropertyPanel, ChangeStartHdl, void*, 
EMPTYARG)
     sal_Int32  nPos = mpLBStart->GetSelectEntryPos();
     if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBStart->IsValueChangedFromSaved() 
)
     {
-        XLineStartItem* pItem = NULL;
+        boost::scoped_ptr<XLineStartItem> pItem;
         if( nPos == 0 )
-            pItem = new XLineStartItem();
+            pItem.reset(new XLineStartItem());
         else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos 
- 1 ) )
-            pItem = new XLineStartItem( 
mpLBStart->GetSelectEntry(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() 
);
-        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, 
SFX_CALLMODE_RECORD, pItem,  0L);
-        delete pItem;
+            pItem.reset(new XLineStartItem( 
mpLBStart->GetSelectEntry(),mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() 
));
+        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, 
SFX_CALLMODE_RECORD, pItem.get(),  0L);
     }
     return 0;
 }
@@ -755,13 +755,12 @@ IMPL_LINK(LinePropertyPanel, ChangeEndHdl, void*, 
EMPTYARG)
     sal_Int32  nPos = mpLBEnd->GetSelectEntryPos();
     if( nPos != LISTBOX_ENTRY_NOTFOUND && mpLBEnd->IsValueChangedFromSaved() )
     {
-        XLineEndItem* pItem = NULL;
+        boost::scoped_ptr<XLineEndItem> pItem;
         if( nPos == 0 )
-            pItem = new XLineEndItem();
+            pItem.reset(new XLineEndItem());
         else if( mxLineEndList.is() && mxLineEndList->Count() > (long) ( nPos 
- 1 ) )
-            pItem = new XLineEndItem( mpLBEnd->GetSelectEntry(), 
mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() );
-        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, 
SFX_CALLMODE_RECORD, pItem,  0L);
-        delete pItem;
+            pItem.reset(new XLineEndItem( mpLBEnd->GetSelectEntry(), 
mxLineEndList->GetLineEnd( nPos - 1 )->GetLineEnd() ));
+        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINEEND_STYLE, 
SFX_CALLMODE_RECORD, pItem.get(),  0L);
     }
     return 0;
 }
@@ -775,34 +774,33 @@ IMPL_LINK(LinePropertyPanel, ChangeEdgeStyleHdl, void*, 
EMPTYARG)
 
     if(LISTBOX_ENTRY_NOTFOUND != nPos && 
mpLBEdgeStyle->IsValueChangedFromSaved())
     {
-        XLineJointItem* pItem = 0;
+        boost::scoped_ptr<XLineJointItem> pItem;
 
         switch(nPos)
         {
             case 0: // rounded
             {
-                pItem = new 
XLineJointItem(com::sun::star::drawing::LineJoint_ROUND);
+                pItem.reset(new 
XLineJointItem(com::sun::star::drawing::LineJoint_ROUND));
                 break;
             }
             case 1: // none
             {
-                pItem = new 
XLineJointItem(com::sun::star::drawing::LineJoint_NONE);
+                pItem.reset(new 
XLineJointItem(com::sun::star::drawing::LineJoint_NONE));
                 break;
             }
             case 2: // mitered
             {
-                pItem = new 
XLineJointItem(com::sun::star::drawing::LineJoint_MITER);
+                pItem.reset(new 
XLineJointItem(com::sun::star::drawing::LineJoint_MITER));
                 break;
             }
             case 3: // beveled
             {
-                pItem = new 
XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL);
+                pItem.reset(new 
XLineJointItem(com::sun::star::drawing::LineJoint_BEVEL));
                 break;
             }
         }
 
-        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, 
SFX_CALLMODE_RECORD, pItem,  0L);
-        delete pItem;
+        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_JOINT, 
SFX_CALLMODE_RECORD, pItem.get(),  0L);
     }
     return 0;
 }
@@ -816,29 +814,28 @@ IMPL_LINK(LinePropertyPanel, ChangeCapStyleHdl, void*, 
EMPTYARG)
 
     if(LISTBOX_ENTRY_NOTFOUND != nPos && 
mpLBCapStyle->IsValueChangedFromSaved())
     {
-        XLineCapItem* pItem = 0;
+        boost::scoped_ptr<XLineCapItem> pItem;
 
         switch(nPos)
         {
             case 0: // flat
             {
-                pItem = new 
XLineCapItem(com::sun::star::drawing::LineCap_BUTT);
+                pItem.reset(new 
XLineCapItem(com::sun::star::drawing::LineCap_BUTT));
                 break;
             }
             case 1: // round
             {
-                pItem = new 
XLineCapItem(com::sun::star::drawing::LineCap_ROUND);
+                pItem.reset(new 
XLineCapItem(com::sun::star::drawing::LineCap_ROUND));
                 break;
             }
             case 2: // square
             {
-                pItem = new 
XLineCapItem(com::sun::star::drawing::LineCap_SQUARE);
+                pItem.reset(new 
XLineCapItem(com::sun::star::drawing::LineCap_SQUARE));
                 break;
             }
         }
 
-        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, 
SFX_CALLMODE_RECORD, pItem,  0L);
-        delete pItem;
+        GetBindings()->GetDispatcher()->Execute(SID_ATTR_LINE_CAP, 
SFX_CALLMODE_RECORD, pItem.get(),  0L);
     }
     return 0;
 }
diff --git a/svx/source/sidebar/nbdtmg.cxx b/svx/source/sidebar/nbdtmg.cxx
index eecb7d2..967cf24 100644
--- a/svx/source/sidebar/nbdtmg.cxx
+++ b/svx/source/sidebar/nbdtmg.cxx
@@ -51,6 +51,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/text/XNumberingTypeInfo.hpp>
+#include <boost/scoped_ptr.hpp>
 
 using namespace com::sun::star;
 using namespace com::sun::star::uno;
@@ -170,7 +171,7 @@ void NBOTypeMgrBase::ImplLoad(const OUString& filename)
     eCoreUnit = SFX_MAPUNIT_100TH_MM;
     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
     aFile.Append( filename);
-    SvStream* pIStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( 
INetURLObject::NO_DECODE ), STREAM_READ );
+    boost::scoped_ptr<SvStream> pIStm(::utl::UcbStreamHelper::CreateStream( 
aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_READ ));
     if( pIStm ) {
         sal_uInt32                  nVersion = 0;
         sal_Int32                   nNumIndex = 0;
@@ -198,7 +199,6 @@ void NBOTypeMgrBase::ImplLoad(const OUString& filename)
                 pIStm->ReadInt32( nNumIndex );
             }
         }
-        delete pIStm;
     }
     eCoreUnit = eOldCoreUnit;
     bIsLoading = false;
@@ -210,7 +210,7 @@ void NBOTypeMgrBase::ImplStore(const OUString& filename)
     eCoreUnit = SFX_MAPUNIT_100TH_MM;
     INetURLObject aFile( SvtPathOptions().GetPalettePath() );
     aFile.Append( filename);
-    SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aFile.GetMainURL( 
INetURLObject::NO_DECODE ), STREAM_WRITE );
+    boost::scoped_ptr<SvStream> pOStm(::utl::UcbStreamHelper::CreateStream( 
aFile.GetMainURL( INetURLObject::NO_DECODE ), STREAM_WRITE ));
     if( pOStm ) {
         sal_uInt32                      nVersion;
         sal_Int32                       nNumIndex;
@@ -228,7 +228,6 @@ void NBOTypeMgrBase::ImplStore(const OUString& filename)
         }
         nNumIndex = -1;
         pOStm->WriteInt32( nNumIndex );  //write end flag
-        delete pOStm;
     }
     eCoreUnit = eOldCoreUnit;
 }
diff --git a/svx/source/svdraw/svdedtv2.cxx b/svx/source/svdraw/svdedtv2.cxx
index 0c34c19..4b73e5a 100644
--- a/svx/source/svdraw/svdedtv2.cxx
+++ b/svx/source/svdraw/svdedtv2.cxx
@@ -42,7 +42,7 @@
 #include <svx/dialogs.hrc>
 #include <svx/svdoashp.hxx>
 #include <basegfx/polygon/b2dpolypolygoncutter.hxx>
-
+#include <boost/scoped_ptr.hpp>
 #include <vector>
 using ::std::vector;
 
@@ -772,7 +772,7 @@ void SdrEditView::DistributeMarkedObjects()
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         if(pFact)
         {
-            AbstractSvxDistributeDialog *pDlg = 
pFact->CreateSvxDistributeDialog(NULL, aNewAttr);
+            boost::scoped_ptr<AbstractSvxDistributeDialog> 
pDlg(pFact->CreateSvxDistributeDialog(NULL, aNewAttr));
             DBG_ASSERT(pDlg, "Dialogdiet fail!");
 
             sal_uInt16 nResult = pDlg->Execute();
@@ -985,8 +985,6 @@ void SdrEditView::DistributeMarkedObjects()
                 if( bUndo )
                     EndUndo();
             }
-
-            delete(pDlg);
         }
     }
 }
diff --git a/svx/source/svdraw/svdedxv.cxx b/svx/source/svdraw/svdedxv.cxx
index c8a7ae7..397ebe7 100644
--- a/svx/source/svdraw/svdedxv.cxx
+++ b/svx/source/svdraw/svdedxv.cxx
@@ -60,7 +60,7 @@
 #include <sdr/overlay/overlaytools.hxx>
 #include <svx/sdr/table/tablecontroller.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
-
+#include <boost/scoped_ptr.hpp>
 
 
 void SdrObjEditView::ImpClearVars()
@@ -342,9 +342,9 @@ void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& 
rOutlView, const Rectang
     {
         // completely reworked to use primitives; this ensures same look and 
functionality
         const drawinglayer::geometry::ViewInformation2D aViewInformation2D;
-        drawinglayer::processor2d::BaseProcessor2D* pProcessor = 
drawinglayer::processor2d::createProcessor2DFromOutputDevice(
+        boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> 
pProcessor(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
             rTargetDevice,
-            aViewInformation2D);
+            aViewInformation2D));
 
         if(pProcessor)
         {
@@ -367,7 +367,6 @@ void SdrObjEditView::ImpPaintOutlinerView(OutlinerView& 
rOutlView, const Rectang
             rTargetDevice.EnableMapMode(false);
             pProcessor->process(aSequence);
             rTargetDevice.EnableMapMode(bMerk);
-            delete pProcessor;
         }
     }
 
diff --git a/svx/source/svdraw/svdhdl.cxx b/svx/source/svdraw/svdhdl.cxx
index 3b334d1..9830fab 100644
--- a/svx/source/svdraw/svdhdl.cxx
+++ b/svx/source/svdraw/svdhdl.cxx
@@ -64,6 +64,8 @@
 #include <drawinglayer/primitive2d/maskprimitive2d.hxx>
 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
+#include <boost/scoped_array.hpp>
+#include <boost/scoped_ptr.hpp>
 
 
 // #i15222#
@@ -990,7 +992,7 @@ Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
     aRetval.Erase(aCol);
 
     // get write access
-    BitmapWriteAccess* pWrite = aRetval.AcquireWriteAccess();
+    boost::scoped_ptr<BitmapWriteAccess> pWrite(aRetval.AcquireWriteAccess());
     DBG_ASSERT(pWrite, "Got NO write access to a new Bitmap!");
 
     if(pWrite)
@@ -1023,9 +1025,6 @@ Bitmap SdrHdlColor::CreateColorDropper(Color aCol)
         pWrite->SetLineColor(aDarkColor);
         pWrite->DrawLine(Point(2, nHeight - 2), Point(nWidth - 2, nHeight - 
2));
         pWrite->DrawLine(Point(nWidth - 2, 2), Point(nWidth - 2, nHeight - 3));
-
-        // get rid of write access
-        delete pWrite;
     }
 
     return aRetval;
@@ -1860,7 +1859,7 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
         }
 
         // allocate pointer array for sorted handle list
-        ImplHdlAndIndex* pHdlAndIndex = new ImplHdlAndIndex[aList.size()];
+        boost::scoped_array<ImplHdlAndIndex> pHdlAndIndex(new 
ImplHdlAndIndex[aList.size()]);
 
         // build sorted handle list
         sal_uInt32 a;
@@ -1870,7 +1869,7 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
             pHdlAndIndex[a].mnIndex = a;
         }
 
-        qsort(pHdlAndIndex, aList.size(), sizeof(ImplHdlAndIndex), 
ImplSortHdlFunc);
+        qsort(pHdlAndIndex.get(), aList.size(), sizeof(ImplHdlAndIndex), 
ImplSortHdlFunc);
 
         // look for old num in sorted array
         sal_uIntPtr nOldHdl(nOldHdlNum);
@@ -1964,9 +1963,6 @@ void SdrHdlList::TravelFocusHdl(bool bForward)
                 pNew->Touch();
             }
         }
-
-        // free memory again
-        delete [] pHdlAndIndex;
     }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to