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

Takeshi Abe tabe at fixedpoint.jp
Mon Jun 23 02:55:04 PDT 2014


 helpcontent2                    |    2 +-
 svx/source/core/extedit.cxx     |    5 ++---
 svx/source/form/fmshimp.cxx     |    8 +++-----
 svx/source/xoutdev/_xoutbmp.cxx |   18 ++++++++----------
 svx/source/xoutdev/xexch.cxx    |    5 ++---
 svx/source/xoutdev/xtabdash.cxx |    7 ++++---
 svx/source/xoutdev/xtabgrdt.cxx |    7 ++++---
 svx/source/xoutdev/xtabhtch.cxx |    7 ++++---
 svx/source/xoutdev/xtablend.cxx |    7 ++++---
 9 files changed, 32 insertions(+), 34 deletions(-)

New commits:
commit b9019d2920e44842926c3fe77c14c14f0af71c90
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Mon Jun 23 14:26:08 2014 +0900

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

diff --git a/helpcontent2 b/helpcontent2
index e420865..d2a1a4f 160000
--- a/helpcontent2
+++ b/helpcontent2
@@ -1 +1 @@
-Subproject commit e4208653997a7390b5129207a11e9fa6d4a8c070
+Subproject commit d2a1a4fa5f1f45b6d137e9792bb3259e062cc3ff
diff --git a/svx/source/core/extedit.cxx b/svx/source/core/extedit.cxx
index 24e93f9..12864cc 100644
--- a/svx/source/core/extedit.cxx
+++ b/svx/source/core/extedit.cxx
@@ -24,6 +24,7 @@
 #include <unotools/ucbstreamhelper.hxx>
 #include <comphelper/processfactory.hxx>
 #include <boost/bind.hpp>
+#include <boost/scoped_ptr.hpp>
 
 #include <com/sun/star/system/SystemShellExecute.hpp>
 #include <com/sun/star/system/SystemShellExecuteFlags.hpp>
@@ -45,15 +46,13 @@ void ExternalToolEdit::HandleCloseEvent(ExternalToolEdit* pData)
     Graphic newGraphic;
 
     //import the temp file image stream into the newGraphic
-    SvStream* pStream = utl::UcbStreamHelper::CreateStream(pData->m_aFileName, STREAM_READ);
+    boost::scoped_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(pData->m_aFileName, STREAM_READ));
     if(pStream)
     {
         GraphicConverter::Import(*pStream, newGraphic);
 
         // Now update the Graphic in the shell by re-reading from the newGraphic
         pData->Update( newGraphic );
-
-        delete(pStream);
     }
 }
 
diff --git a/svx/source/form/fmshimp.cxx b/svx/source/form/fmshimp.cxx
index 0c53aec..73f2f17 100644
--- a/svx/source/form/fmshimp.cxx
+++ b/svx/source/form/fmshimp.cxx
@@ -101,6 +101,7 @@
 #include <functional>
 #include <map>
 #include <vector>
+#include <boost/scoped_ptr.hpp>
 
 // wird fuer Invalidate verwendet -> mitpflegen
 static const sal_uInt16 DatabaseSlotMap[] =
@@ -285,10 +286,10 @@ namespace
         {
             SdrObject* pCurrent = _rMarkList.GetMark( i )->GetMarkedSdrObj();
 
-            SdrObjListIter* pGroupIterator = NULL;
+            boost::scoped_ptr<SdrObjListIter> pGroupIterator;
             if ( pCurrent->IsGroupObject() )
             {
-                pGroupIterator = new SdrObjListIter( *pCurrent->GetSubList() );
+                pGroupIterator.reset(new SdrObjListIter( *pCurrent->GetSubList() ));
                 pCurrent = pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
             }
 
@@ -307,9 +308,6 @@ namespace
                 // next element
                 pCurrent = pGroupIterator && pGroupIterator->IsMore() ? pGroupIterator->Next() : NULL;
             }
-
-            if ( pGroupIterator )
-                delete pGroupIterator;
         }
     }
 
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index b7adb4f..da0ca01 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -31,6 +31,7 @@
 #include <vcl/graphicfilter.hxx>
 #include <vcl/cvtgrf.hxx>
 #include <sax/tools/converter.hxx>
+#include <boost/scoped_array.hpp>
 
 #define FORMAT_BMP  OUString("bmp")
 #define FORMAT_GIF  OUString("gif")
@@ -506,16 +507,16 @@ Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nFlags,
             const long          nStartY1 = aWorkRect.Top() + 1L;
             const long          nEndY1 = aWorkRect.Bottom();
             const long          nStartY2 = nEndY1 - 1L;
-            Point*              pPoints1 = NULL;
-            Point*              pPoints2 = NULL;
+            boost::scoped_array<Point> pPoints1;
+            boost::scoped_array<Point> pPoints2;
             long                nX, nY;
             sal_uInt16              nPolyPos = 0;
             const BitmapColor   aBlack = pAcc->GetBestMatchingColor( Color( COL_BLACK ) );
 
             if( nFlags & XOUTBMP_CONTOUR_VERT )
             {
-                pPoints1 = new Point[ nWidth ];
-                pPoints2 = new Point[ nWidth ];
+                pPoints1.reset(new Point[ nWidth ]);
+                pPoints2.reset(new Point[ nWidth ]);
 
                 for( nX = nStartX1; nX < nEndX1; nX++ )
                 {
@@ -551,8 +552,8 @@ Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nFlags,
             }
             else
             {
-                pPoints1 = new Point[ nHeight ];
-                pPoints2 = new Point[ nHeight ];
+                pPoints1.reset(new Point[ nHeight ]);
+                pPoints2.reset(new Point[ nHeight ]);
 
                 for ( nY = nStartY1; nY < nEndY1; nY++ )
                 {
@@ -589,7 +590,7 @@ Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nFlags,
 
             const sal_uInt16 nNewSize1 = nPolyPos << 1;
 
-            aRetPoly = Polygon( nPolyPos, pPoints1 );
+            aRetPoly = Polygon( nPolyPos, pPoints1.get() );
             aRetPoly.SetSize( nNewSize1 + 1 );
             aRetPoly[ nNewSize1 ] = aRetPoly[ 0 ];
 
@@ -598,9 +599,6 @@ Polygon XOutBitmap::GetCountour( const Bitmap& rBmp, const sal_uIntPtr nFlags,
 
             if( ( fFactorX != 0. ) && ( fFactorY != 0. ) )
                 aRetPoly.Scale( fFactorX, fFactorY );
-
-            delete[] pPoints1;
-            delete[] pPoints2;
         }
     }
 
diff --git a/svx/source/xoutdev/xexch.cxx b/svx/source/xoutdev/xexch.cxx
index c93a647..62eb2f1 100644
--- a/svx/source/xoutdev/xexch.cxx
+++ b/svx/source/xoutdev/xexch.cxx
@@ -26,6 +26,7 @@
 #include <svl/itemset.hxx>
 #include <svx/xdef.hxx>
 #include "svx/xexch.hxx"
+#include <boost/scoped_ptr.hpp>
 
 
 TYPEINIT1_AUTOFACTORY( XFillExchangeData, SvDataCopyStream );
@@ -92,7 +93,6 @@ SvStream& ReadXFillExchangeData( SvStream& rIStm, XFillExchangeData& rData )
     DBG_ASSERT( rData.pPool, "XFillExchangeData has no pool" );
 
     SfxItemSet*     pSet = new SfxItemSet ( *rData.pPool, XATTR_FILL_FIRST, XATTR_FILL_LAST );
-    SfxPoolItem*    pNewItem;
     sal_uInt32      nItemCount = 0;
     sal_uInt16          nWhich, nItemVersion;
 
@@ -109,12 +109,11 @@ SvStream& ReadXFillExchangeData( SvStream& rIStm, XFillExchangeData& rData )
 
         if( nWhich )
         {
-            pNewItem = rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion );
+            boost::scoped_ptr<SfxPoolItem> pNewItem(rData.pPool->GetDefaultItem( nWhich ).Create( rIStm, nItemVersion ));
 
             if( pNewItem )
             {
                 pSet->Put( *pNewItem );
-                delete pNewItem;
             }
         }
     }
diff --git a/svx/source/xoutdev/xtabdash.cxx b/svx/source/xoutdev/xtabdash.cxx
index c3fda78..c9414cb 100644
--- a/svx/source/xoutdev/xtabdash.cxx
+++ b/svx/source/xoutdev/xtabdash.cxx
@@ -31,6 +31,7 @@
 #include <drawinglayer/attribute/strokeattribute.hxx>
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace com::sun::star;
 
@@ -158,16 +159,16 @@ Bitmap XDashList::ImpCreateBitmapForXDash(const XDash* pDash)
     }
 
     // create processor and draw primitives
-    drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+    boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
         aVirtualDevice,
-        aNewViewInformation2D);
+        aNewViewInformation2D));
 
     if(pProcessor2D)
     {
         const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aLinePrimitive, 1);
 
         pProcessor2D->process(aSequence);
-        delete pProcessor2D;
+        pProcessor2D.reset();
     }
 
     // get result bitmap and scale
diff --git a/svx/source/xoutdev/xtabgrdt.cxx b/svx/source/xoutdev/xtabgrdt.cxx
index c0ac709..efd6257 100644
--- a/svx/source/xoutdev/xtabgrdt.cxx
+++ b/svx/source/xoutdev/xtabgrdt.cxx
@@ -32,6 +32,7 @@
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace com::sun::star;
 
@@ -189,9 +190,9 @@ Bitmap XGradientList::CreateBitmapForUI( long nIndex )
             : DRAWMODE_DEFAULT);
 
         // create processor and draw primitives
-        drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+        boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
             aVirtualDevice,
-            aNewViewInformation2D);
+            aNewViewInformation2D));
 
         if(pProcessor2D)
         {
@@ -201,7 +202,7 @@ Bitmap XGradientList::CreateBitmapForUI( long nIndex )
             aSequence[1] = aBlackRectanglePrimitive;
 
             pProcessor2D->process(aSequence);
-            delete pProcessor2D;
+            pProcessor2D.reset();
         }
 
         // get result bitmap and scale
diff --git a/svx/source/xoutdev/xtabhtch.cxx b/svx/source/xoutdev/xtabhtch.cxx
index e92551b..ff69551 100644
--- a/svx/source/xoutdev/xtabhtch.cxx
+++ b/svx/source/xoutdev/xtabhtch.cxx
@@ -31,6 +31,7 @@
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::rtl;
@@ -165,9 +166,9 @@ Bitmap XHatchList::CreateBitmapForUI( long nIndex )
         }
 
         // create processor and draw primitives
-        drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+        boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
             aVirtualDevice,
-            aNewViewInformation2D);
+            aNewViewInformation2D));
 
         if(pProcessor2D)
         {
@@ -176,7 +177,7 @@ Bitmap XHatchList::CreateBitmapForUI( long nIndex )
             aSequence[0] = aHatchPrimitive;
             aSequence[1] = aBlackRectanglePrimitive;
             pProcessor2D->process(aSequence);
-            delete pProcessor2D;
+            pProcessor2D.reset();
         }
 
         // get result bitmap and scale
diff --git a/svx/source/xoutdev/xtablend.cxx b/svx/source/xoutdev/xtablend.cxx
index a59ac71..546b0a6 100644
--- a/svx/source/xoutdev/xtablend.cxx
+++ b/svx/source/xoutdev/xtablend.cxx
@@ -31,6 +31,7 @@
 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
 #include <drawinglayer/processor2d/processor2dtools.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
+#include <boost/scoped_ptr.hpp>
 
 using namespace com::sun::star;
 
@@ -147,16 +148,16 @@ Bitmap XLineEndList::CreateBitmapForUI( long nIndex )
         }
 
         // create processor and draw primitives
-        drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
+        boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createPixelProcessor2DFromOutputDevice(
             aVirtualDevice,
-            aNewViewInformation2D);
+            aNewViewInformation2D));
 
         if(pProcessor2D)
         {
             const drawinglayer::primitive2d::Primitive2DSequence aSequence(&aLineStartEndPrimitive, 1);
 
             pProcessor2D->process(aSequence);
-            delete pProcessor2D;
+            pProcessor2D.reset();
         }
 
         // get result bitmap and scale


More information about the Libreoffice-commits mailing list