From cedce25eba798dda36a7e786922154e1faefa865 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Mon, 27 May 2019 10:32:27 +0900 Subject: [PATCH] Fixed regression in VPath::Clone() api and updated test cases --- src/vector/vpath.h | 6 +++--- test/test_lottieanimation.cpp | 2 +- test/test_vpath.cpp | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/vector/vpath.h b/src/vector/vpath.h index 598f10a..2c044e8 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -99,6 +99,7 @@ private: float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW); void addPath(const VPathData &path); + void clone(const VPath::VPathData &o) { *this = o;} const std::vector &elements() const { return m_elements; @@ -262,10 +263,9 @@ inline const std::vector &VPath::points() const return d->points(); } -inline void VPath::clone(const VPath &srcPath) +inline void VPath::clone(const VPath &o) { - reset(); - addPath(srcPath); + d.write().clone(o.d.read()); } V_END_NAMESPACE diff --git a/test/test_lottieanimation.cpp b/test/test_lottieanimation.cpp index d704fb4..086981a 100644 --- a/test/test_lottieanimation.cpp +++ b/test/test_lottieanimation.cpp @@ -25,7 +25,7 @@ TEST_F(AnimationTest, loadFromFile_N) { } TEST_F(AnimationTest, loadFromFile) { - ASSERT_TRUE(animation); + ASSERT_TRUE(animation != nullptr); ASSERT_EQ(animation->totalFrame(), 29); size_t width, height; animation->size(width, height); diff --git a/test/test_vpath.cpp b/test/test_vpath.cpp index 8ae7e96..01e2d3c 100644 --- a/test/test_vpath.cpp +++ b/test/test_vpath.cpp @@ -69,6 +69,7 @@ TEST_F(VPathTest, reserve) { TEST_F(VPathTest, clone) { VPath pathClone; pathClone.clone(pathOval); + ASSERT_TRUE(pathClone.unique()); ASSERT_EQ(pathClone.segments(), pathOval.segments()); ASSERT_EQ(pathClone.points().size(), pathOval.points().size()); ASSERT_NE(pathClone.points().data(), pathOval.points().data()); -- 2.7.4