diff options
author | Mark Page <aptitude@btconnect.com> | 2016-12-05 12:25:30 +0000 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-06 09:23:55 +0000 |
commit | 13e77648265a91ec2b7d649d30a108e4e1eff3c8 (patch) | |
tree | 807a7acaad95374f5f434c3d0a414967345abcfd /drawinglayer | |
parent | 9b8fb821504079e6fb1636dad06e7644a302f39f (diff) |
Use std::unique_ptr for AnimationEntry
Change-Id: Ia089be3677adadb4250003b78b7c6bc15ab8bc42
Reviewed-on: https://gerrit.libreoffice.org/31631
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/animation/animationtiming.cxx | 30 | ||||
-rw-r--r-- | drawinglayer/source/primitive2d/animatedprimitive2d.cxx | 6 |
2 files changed, 13 insertions, 23 deletions
diff --git a/drawinglayer/source/animation/animationtiming.cxx b/drawinglayer/source/animation/animationtiming.cxx index 72400c1cd5dd..683c5f5b830c 100644 --- a/drawinglayer/source/animation/animationtiming.cxx +++ b/drawinglayer/source/animation/animationtiming.cxx @@ -19,7 +19,7 @@ #include <drawinglayer/animation/animationtiming.hxx> #include <basegfx/numeric/ftools.hxx> - +#include <o3tl/make_unique.hxx> namespace drawinglayer { @@ -46,9 +46,9 @@ namespace drawinglayer { } - AnimationEntry* AnimationEntryFixed::clone() const + std::unique_ptr<AnimationEntry> AnimationEntryFixed::clone() const { - return new AnimationEntryFixed(mfDuration, mfState); + return o3tl::make_unique<AnimationEntryFixed>(mfDuration, mfState); } bool AnimationEntryFixed::operator==(const AnimationEntry& rCandidate) const @@ -95,9 +95,9 @@ namespace drawinglayer { } - AnimationEntry* AnimationEntryLinear::clone() const + std::unique_ptr<AnimationEntry> AnimationEntryLinear::clone() const { - return new AnimationEntryLinear(mfDuration, mfFrequency, mfStart, mfStop); + return o3tl::make_unique<AnimationEntryLinear>(mfDuration, mfFrequency, mfStart, mfStop); } bool AnimationEntryLinear::operator==(const AnimationEntry& rCandidate) const @@ -178,22 +178,18 @@ namespace drawinglayer AnimationEntryList::~AnimationEntryList() { - for(AnimationEntry* i : maEntries) - { - delete i; - } } - AnimationEntry* AnimationEntryList::clone() const + std::unique_ptr<AnimationEntry> AnimationEntryList::clone() const { - AnimationEntryList* pNew = new AnimationEntryList(); + std::unique_ptr<AnimationEntryList> pNew(o3tl::make_unique<AnimationEntryList>()); - for(AnimationEntry* i : maEntries) + for(const auto &i : maEntries) { pNew->append(*i); } - return pNew; + return std::move(pNew); } bool AnimationEntryList::operator==(const AnimationEntry& rCandidate) const @@ -277,16 +273,16 @@ namespace drawinglayer { } - AnimationEntry* AnimationEntryLoop::clone() const + std::unique_ptr<AnimationEntry> AnimationEntryLoop::clone() const { - AnimationEntryLoop* pNew = new AnimationEntryLoop(mnRepeat); + std::unique_ptr<AnimationEntryLoop> pNew(o3tl::make_unique<AnimationEntryLoop>(mnRepeat)); - for(AnimationEntry* i : maEntries) + for(const auto &i : maEntries) { pNew->append(*i); } - return pNew; + return std::move(pNew); } bool AnimationEntryLoop::operator==(const AnimationEntry& rCandidate) const diff --git a/drawinglayer/source/primitive2d/animatedprimitive2d.cxx b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx index 713c4bd52bcd..13564af2bce5 100644 --- a/drawinglayer/source/primitive2d/animatedprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/animatedprimitive2d.cxx @@ -33,9 +33,6 @@ namespace drawinglayer { void AnimatedSwitchPrimitive2D::setAnimationEntry(const animation::AnimationEntry& rNew) { - // delete cloned animation description - delete mpAnimationEntry; - // clone given animation description mpAnimationEntry = rNew.clone(); } @@ -45,7 +42,6 @@ namespace drawinglayer const Primitive2DContainer& rChildren, bool bIsTextAnimation) : GroupPrimitive2D(rChildren), - mpAnimationEntry(nullptr), mbIsTextAnimation(bIsTextAnimation) { // clone given animation description @@ -54,8 +50,6 @@ namespace drawinglayer AnimatedSwitchPrimitive2D::~AnimatedSwitchPrimitive2D() { - // delete cloned animation description - delete mpAnimationEntry; } bool AnimatedSwitchPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const |