From 8a9f8d35b000e37f08d391958eca0d51269a23dd Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Wed, 28 Feb 2018 09:49:08 +0200 Subject: loplugin:useuniqueptr in SvgPathNode Change-Id: I8e4485a308edecf05a2bc70d5c067af3b0eef5d1 Reviewed-on: https://gerrit.libreoffice.org/50654 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svgio/inc/svgpathnode.hxx | 12 ++++++------ svgio/source/svgreader/svgpathnode.cxx | 2 -- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'svgio') diff --git a/svgio/inc/svgpathnode.hxx b/svgio/inc/svgpathnode.hxx index 3cd23232a8ee..a96910560b2e 100644 --- a/svgio/inc/svgpathnode.hxx +++ b/svgio/inc/svgpathnode.hxx @@ -35,8 +35,8 @@ namespace svgio SvgStyleAttributes maSvgStyleAttributes; /// variable scan values, dependent of given XAttributeList - basegfx::B2DPolyPolygon* mpPolyPolygon; - basegfx::B2DHomMatrix* mpaTransform; + std::unique_ptr mpPolyPolygon; + std::unique_ptr mpaTransform; SvgNumber maPathLength; basegfx::utils::PointIndexSet maHelpPointIndices; @@ -51,12 +51,12 @@ namespace svgio virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override; /// path content, set if found in current context - const basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon; } - void setPath(const basegfx::B2DPolyPolygon* pPath) { if(mpPolyPolygon) delete mpPolyPolygon; mpPolyPolygon = nullptr; if(pPath) mpPolyPolygon = new basegfx::B2DPolyPolygon(*pPath); } + const basegfx::B2DPolyPolygon* getPath() const { return mpPolyPolygon.get(); } + void setPath(const basegfx::B2DPolyPolygon* pPath) { mpPolyPolygon.reset(); if(pPath) mpPolyPolygon.reset(new basegfx::B2DPolyPolygon(*pPath)); } /// transform content, set if found in current context - const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; } - void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); } + const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); } + void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset(new basegfx::B2DHomMatrix(*pMatrix)); } /// PathLength content const SvgNumber& getPathLength() const { return maPathLength; } diff --git a/svgio/source/svgreader/svgpathnode.cxx b/svgio/source/svgreader/svgpathnode.cxx index 50fe2e52151e..051f4fb9972b 100644 --- a/svgio/source/svgreader/svgpathnode.cxx +++ b/svgio/source/svgreader/svgpathnode.cxx @@ -37,8 +37,6 @@ namespace svgio SvgPathNode::~SvgPathNode() { - delete mpPolyPolygon; - delete mpaTransform; } const SvgStyleAttributes* SvgPathNode::getSvgStyleAttributes() const -- cgit