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