[Tizen](Vector) Fix memory leak 56/222256/1
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 13 Jan 2020 05:05:50 +0000 (14:05 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Mon, 13 Jan 2020 05:18:21 +0000 (14:18 +0900)
Sometimes the VectorAnimationTask was not destructed because it tried to rasterize repeatedly.

Change-Id: I308cba1d2affb6378a5419721ab225de3c312677

dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.h

index 7487d6d..9bbf7e0 100644 (file)
@@ -105,6 +105,8 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor
 
 AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
 {
+  SendAnimationData();
+
   if( mRasterizationTriggered && Adaptor::IsAvailable() )
   {
     Adaptor::Get().UnregisterProcessor( *this );
index 0455db3..871683f 100644 (file)
@@ -85,7 +85,8 @@ VectorAnimationTask::VectorAnimationTask( VisualFactoryCache& factoryCache, cons
   mForward( true ),
   mUpdateFrameNumber( false ),
   mNeedAnimationFinishedTrigger( true ),
-  mForceRender( false )
+  mForceRender( false ),
+  mDestroyTask( false )
 {
   Initialize();
 }
@@ -106,6 +107,8 @@ void VectorAnimationTask::Finalize()
   }
 
   mVectorRenderer.Finalize();
+
+  mDestroyTask = true;
 }
 
 void VectorAnimationTask::SetRenderer( Renderer renderer )
@@ -477,6 +480,12 @@ bool VectorAnimationTask::Rasterize()
   {
     ConditionalWait::ScopedLock lock( mConditionalWait );
 
+    if( mDestroyTask )
+    {
+      // The task will be destroyed. We don't need rasterization.
+      return false;
+    }
+
     if( mPlayState == PlayState::PLAYING && mUpdateFrameNumber )
     {
       mCurrentFrame = mForward ? mCurrentFrame + 1 : mCurrentFrame - 1;
index 6d24518..4cd2f18 100644 (file)
@@ -306,6 +306,7 @@ private:
   bool                                   mUpdateFrameNumber;
   bool                                   mNeedAnimationFinishedTrigger;
   bool                                   mForceRender;
+  bool                                   mDestroyTask;
 
 };