Merge "(Vector) Fix crash issues" into devel/master
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 1 Jun 2020 08:06:22 +0000 (08:06 +0000)
committerGerrit Code Review <gerrit@review>
Mon, 1 Jun 2020 08:06:22 +0000 (08:06 +0000)
dali-toolkit/internal/visuals/animated-vector-image/animated-vector-image-visual.cpp
dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp

index ec041e9..1793fbc 100644 (file)
@@ -118,7 +118,8 @@ AnimatedVectorImageVisual::AnimatedVectorImageVisual( VisualFactoryCache& factor
 
 AnimatedVectorImageVisual::~AnimatedVectorImageVisual()
 {
-  // Finalize animation task in the main thread
+  // Finalize animation task and disconnect the signal in the main thread
+  mVectorAnimationTask->UploadCompletedSignal().Disconnect( this, &AnimatedVectorImageVisual::OnUploadCompleted );
   mVectorAnimationTask->Finalize();
 }
 
index ae66146..e0c08bd 100644 (file)
@@ -96,6 +96,8 @@ VectorAnimationTask::~VectorAnimationTask()
 
 void VectorAnimationTask::Finalize()
 {
+  ConditionalWait::ScopedLock lock( mConditionalWait );
+
   // Release some objects in the main thread
   if( mAnimationFinishedTrigger )
   {
@@ -418,7 +420,7 @@ void VectorAnimationTask::Initialize()
 
 bool VectorAnimationTask::Rasterize()
 {
-  bool stopped = false, needAnimationFinishedTrigger;
+  bool stopped = false, needAnimationFinishedTrigger, resourceReady;
   uint32_t currentFrame, startFrame, endFrame;
   int32_t loopCount, currentLoopCount;
   PlayState playState;
@@ -439,6 +441,7 @@ bool VectorAnimationTask::Rasterize()
     currentLoopCount = mCurrentLoop;
     needAnimationFinishedTrigger = mNeedAnimationFinishedTrigger;
     playState = mPlayState;
+    resourceReady = mResourceReady;
 
     mResourceReady = true;
     mCurrentFrameUpdated = false;
@@ -513,11 +516,19 @@ bool VectorAnimationTask::Rasterize()
     {
       DALI_LOG_INFO( gVectorAnimationLogFilter, Debug::Verbose, "VectorAnimationTask::Rasterize: Rendering failed. Try again later.[%d] [%p]\n", currentFrame, this );
       mUpdateFrameNumber = false;
+
+      if( !resourceReady )
+      {
+        ConditionalWait::ScopedLock lock( mConditionalWait );
+        mResourceReady = false;
+      }
     }
   }
 
   if( stopped && renderSuccess )
   {
+    ConditionalWait::ScopedLock lock( mConditionalWait );
+
     mPlayState = PlayState::STOPPED;
     mForward = true;
     mCurrentLoop = 0;