Kaydet (Commit) c60f6227 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible memory leaks in case of exceptions

Change-Id: I1d703da6c0f9fd1a7e2423cc609fb504bb553382
üst 822cf7cb
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx> #include <drawinglayer/processor2d/processor2dtools.hxx>
#include <svx/unoapi.hxx> #include <svx/unoapi.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -127,14 +127,13 @@ namespace sdr ...@@ -127,14 +127,13 @@ namespace sdr
// if there is something to show, use a vclProcessor to render it // if there is something to show, use a vclProcessor to render it
if(xPrimitiveSequence.hasElements()) if(xPrimitiveSequence.hasElements())
{ {
drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = drawinglayer::processor2d::createProcessor2DFromOutputDevice( boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
*pTargetDevice, *pTargetDevice,
getViewInformation2D()); getViewInformation2D()));
if(pProcessor2D) if(pProcessor2D)
{ {
pProcessor2D->process(xPrimitiveSequence); pProcessor2D->process(xPrimitiveSequence);
delete pProcessor2D;
} }
} }
} }
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <svx/unoapi.hxx> #include <svx/unoapi.hxx>
#include "eventhandler.hxx" #include "eventhandler.hxx"
#include <boost/scoped_ptr.hpp>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -284,14 +285,13 @@ namespace sdr ...@@ -284,14 +285,13 @@ namespace sdr
pOutDev->SetLayoutMode(0); // reset, default is no BiDi/RTL pOutDev->SetLayoutMode(0); // reset, default is no BiDi/RTL
// create renderer // create renderer
drawinglayer::processor2d::BaseProcessor2D* pProcessor2D = boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor2D(
drawinglayer::processor2d::createProcessor2DFromOutputDevice( drawinglayer::processor2d::createProcessor2DFromOutputDevice(
rTargetOutDev, getViewInformation2D()); rTargetOutDev, getViewInformation2D()));
if(pProcessor2D) if(pProcessor2D)
{ {
pProcessor2D->process(xPrimitiveSequence); pProcessor2D->process(xPrimitiveSequence);
delete pProcessor2D;
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
#include <sdr/primitive3d/sdrattributecreator3d.hxx> #include <sdr/primitive3d/sdrattributecreator3d.hxx>
#include <basegfx/range/b3drange.hxx> #include <basegfx/range/b3drange.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -71,7 +71,7 @@ namespace sdr ...@@ -71,7 +71,7 @@ namespace sdr
aWorldTransform.translate(aCubeRange.getMinX(), aCubeRange.getMinY(), aCubeRange.getMinZ()); aWorldTransform.translate(aCubeRange.getMinX(), aCubeRange.getMinY(), aCubeRange.getMinZ());
// get 3D Object Attributes // get 3D Object Attributes
drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); boost::scoped_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
// calculate texture size to get a perfect mapping for // calculate texture size to get a perfect mapping for
// the front/back sides // the front/back sides
...@@ -83,9 +83,6 @@ namespace sdr ...@@ -83,9 +83,6 @@ namespace sdr
aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute)); aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
// delete 3D Object Attributes
delete pSdr3DObjectAttribute;
return xRetval; return xRetval;
} }
} // end of namespace contact } // end of namespace contact
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
#include <sdr/primitive3d/sdrattributecreator3d.hxx> #include <sdr/primitive3d/sdrattributecreator3d.hxx>
#include <basegfx/polygon/b2dpolypolygontools.hxx> #include <basegfx/polygon/b2dpolypolygontools.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -51,7 +51,7 @@ namespace sdr ...@@ -51,7 +51,7 @@ namespace sdr
const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dExtrudeObj().GetExtrudePolygon()); const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dExtrudeObj().GetExtrudePolygon());
// get 3D Object Attributes // get 3D Object Attributes
drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); boost::scoped_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
// calculate texture size; use size of top/bottom cap to get a perfect mapping // calculate texture size; use size of top/bottom cap to get a perfect mapping
// for the caps. The in-between geometry will get a stretched size with a // for the caps. The in-between geometry will get a stretched size with a
...@@ -78,9 +78,6 @@ namespace sdr ...@@ -78,9 +78,6 @@ namespace sdr
bCharacterMode, bCloseFront, bCloseBack)); bCharacterMode, bCloseFront, bCloseBack));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
// delete 3D Object Attributes
delete pSdr3DObjectAttribute;
return xRetval; return xRetval;
} }
} // end of namespace contact } // end of namespace contact
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
#include <sdr/primitive3d/sdrattributecreator3d.hxx> #include <sdr/primitive3d/sdrattributecreator3d.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx> #include <basegfx/polygon/b2dpolygontools.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -51,7 +51,7 @@ namespace sdr ...@@ -51,7 +51,7 @@ namespace sdr
const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D()); const basegfx::B2DPolyPolygon aPolyPolygon(GetE3dLatheObj().GetPolyPoly2D());
// get 3D Object Attributes // get 3D Object Attributes
drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); boost::scoped_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
// calculate texture size. Use the polygon length of the longest polygon for // calculate texture size. Use the polygon length of the longest polygon for
// height and the rotated radius for width (using polygon center) to get a good // height and the rotated radius for width (using polygon center) to get a good
...@@ -93,9 +93,6 @@ namespace sdr ...@@ -93,9 +93,6 @@ namespace sdr
bSmoothNormals, true, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack)); bSmoothNormals, true, bSmoothLids, bCharacterMode, bCloseFront, bCloseBack));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
// delete 3D Object Attributes
delete pSdr3DObjectAttribute;
return xRetval; return xRetval;
} }
} // end of namespace contact } // end of namespace contact
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <sdr/primitive3d/sdrattributecreator3d.hxx> #include <sdr/primitive3d/sdrattributecreator3d.hxx>
#include <basegfx/polygon/b3dpolygon.hxx> #include <basegfx/polygon/b3dpolygon.hxx>
#include <basegfx/polygon/b3dpolypolygontools.hxx> #include <basegfx/polygon/b3dpolypolygontools.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -99,7 +99,7 @@ namespace sdr ...@@ -99,7 +99,7 @@ namespace sdr
} }
// get 3D Object Attributes // get 3D Object Attributes
drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); boost::scoped_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
// calculate texture size // calculate texture size
basegfx::B2DVector aTextureSize(1.0, 1.0); basegfx::B2DVector aTextureSize(1.0, 1.0);
...@@ -164,9 +164,6 @@ namespace sdr ...@@ -164,9 +164,6 @@ namespace sdr
aPolyPolygon3D, aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute)); aPolyPolygon3D, aWorldTransform, aTextureSize, aAttribute, *pSdr3DObjectAttribute));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
// delete 3D Object Attributes
delete pSdr3DObjectAttribute;
return xRetval; return xRetval;
} }
} // end of namespace contact } // end of namespace contact
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <drawinglayer/primitive3d/sdrsphereprimitive3d.hxx> #include <drawinglayer/primitive3d/sdrsphereprimitive3d.hxx>
#include <svx/sdr/primitive2d/sdrattributecreator.hxx> #include <svx/sdr/primitive2d/sdrattributecreator.hxx>
#include <sdr/primitive3d/sdrattributecreator3d.hxx> #include <sdr/primitive3d/sdrattributecreator3d.hxx>
#include <boost/scoped_ptr.hpp>
namespace sdr namespace sdr
...@@ -57,7 +57,7 @@ namespace sdr ...@@ -57,7 +57,7 @@ namespace sdr
aWorldTransform.translate(aSpherePosition.getX(), aSpherePosition.getY(), aSpherePosition.getZ()); aWorldTransform.translate(aSpherePosition.getX(), aSpherePosition.getY(), aSpherePosition.getZ());
// get 3D Object Attributes // get 3D Object Attributes
drawinglayer::attribute::Sdr3DObjectAttribute* pSdr3DObjectAttribute = drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet); boost::scoped_ptr<drawinglayer::attribute::Sdr3DObjectAttribute> pSdr3DObjectAttribute(drawinglayer::primitive2d::createNewSdr3DObjectAttribute(rItemSet));
// get segment count // get segment count
const sal_uInt32 nHorizontalSegments(GetE3dSphereObj().GetHorizontalSegments()); const sal_uInt32 nHorizontalSegments(GetE3dSphereObj().GetHorizontalSegments());
...@@ -76,9 +76,6 @@ namespace sdr ...@@ -76,9 +76,6 @@ namespace sdr
nHorizontalSegments, nVerticalSegments)); nHorizontalSegments, nVerticalSegments));
xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1); xRetval = drawinglayer::primitive3d::Primitive3DSequence(&xReference, 1);
// delete 3D Object Attributes
delete pSdr3DObjectAttribute;
return xRetval; return xRetval;
} }
} // end of namespace contact } // end of namespace contact
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <svx/sdr/overlay/overlayobject.hxx> #include <svx/sdr/overlay/overlayobject.hxx>
#include <basegfx/matrix/b2dhommatrix.hxx> #include <basegfx/matrix/b2dhommatrix.hxx>
#include <drawinglayer/processor2d/processor2dtools.hxx> #include <drawinglayer/processor2d/processor2dtools.hxx>
#include <boost/scoped_ptr.hpp>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -47,9 +47,9 @@ namespace sdr ...@@ -47,9 +47,9 @@ namespace sdr
const bool bIsAntiAliasing(getDrawinglayerOpt().IsAntiAliasing()); const bool bIsAntiAliasing(getDrawinglayerOpt().IsAntiAliasing());
// create processor // create processor
drawinglayer::processor2d::BaseProcessor2D* pProcessor = drawinglayer::processor2d::createProcessor2DFromOutputDevice( boost::scoped_ptr<drawinglayer::processor2d::BaseProcessor2D> pProcessor(drawinglayer::processor2d::createProcessor2DFromOutputDevice(
rDestinationDevice, rDestinationDevice,
getCurrentViewInformation2D()); getCurrentViewInformation2D()));
if(pProcessor) if(pProcessor)
{ {
...@@ -81,7 +81,7 @@ namespace sdr ...@@ -81,7 +81,7 @@ namespace sdr
} }
} }
delete pProcessor; pProcessor.reset();
} }
// restore AA settings // restore AA settings
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx> #include <svx/sdr/primitive2d/svx_primitivetypes2d.hxx>
#include <basegfx/matrix/b2dhommatrixtools.hxx> #include <basegfx/matrix/b2dhommatrixtools.hxx>
#include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx> #include <drawinglayer/primitive2d/hiddengeometryprimitive2d.hxx>
#include <boost/scoped_ptr.hpp>
using namespace com::sun::star; using namespace com::sun::star;
...@@ -86,7 +86,7 @@ namespace drawinglayer ...@@ -86,7 +86,7 @@ namespace drawinglayer
Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const Primitive2DSequence SdrMeasurePrimitive2D::create2DDecomposition(const geometry::ViewInformation2D& aViewInformation) const
{ {
Primitive2DSequence aRetval; Primitive2DSequence aRetval;
SdrBlockTextPrimitive2D* pBlockText = 0; boost::scoped_ptr<SdrBlockTextPrimitive2D> pBlockText;
basegfx::B2DRange aTextRange; basegfx::B2DRange aTextRange;
double fTextX((getStart().getX() + getEnd().getX()) * 0.5); double fTextX((getStart().getX() + getEnd().getX()) * 0.5);
double fTextY((getStart().getX() + getEnd().getX()) * 0.5); double fTextY((getStart().getX() + getEnd().getX()) * 0.5);
...@@ -125,7 +125,7 @@ namespace drawinglayer ...@@ -125,7 +125,7 @@ namespace drawinglayer
} }
// create primitive and get text range // create primitive and get text range
pBlockText = new SdrBlockTextPrimitive2D( pBlockText.reset(new SdrBlockTextPrimitive2D(
&rTextAttribute.getSdrText(), &rTextAttribute.getSdrText(),
rTextAttribute.getOutlinerParaObject(), rTextAttribute.getOutlinerParaObject(),
aTextMatrix, aTextMatrix,
...@@ -135,7 +135,7 @@ namespace drawinglayer ...@@ -135,7 +135,7 @@ namespace drawinglayer
false, false,
false, false,
false, false,
false); false));
aTextRange = pBlockText->getB2DRange(aViewInformation); aTextRange = pBlockText->getB2DRange(aViewInformation);
} }
...@@ -421,7 +421,7 @@ namespace drawinglayer ...@@ -421,7 +421,7 @@ namespace drawinglayer
// apply to existing text primitive // apply to existing text primitive
SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange); SdrTextPrimitive2D* pNewBlockText = pBlockText->createTransformedClone(aChange);
OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)"); OSL_ENSURE(pNewBlockText, "SdrMeasurePrimitive2D::create2DDecomposition: Could not create transformed clone of text primitive (!)");
delete pBlockText; pBlockText.reset();
// add to local primitives // add to local primitives
appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, Primitive2DReference(pNewBlockText)); appendPrimitive2DReferenceToPrimitive2DSequence(aRetval, Primitive2DReference(pNewBlockText));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment