(Vector) Fix a crash issue submit/tizen_5.5/20191121.042511
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 20 Nov 2019 09:02:42 +0000 (18:02 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 20 Nov 2019 09:02:46 +0000 (18:02 +0900)
Change-Id: I3900768dd378a3c349e5f0dea7a0fc4431930d87

dali-extension/vector-animation-renderer/tizen-vector-animation-manager.cpp
dali-extension/vector-animation-renderer/tizen-vector-animation-renderer.cpp

index c9e163c..557bdfd 100755 (executable)
@@ -74,6 +74,16 @@ void TizenVectorAnimationManager::RemoveEventHandler( TizenVectorAnimationEventH
       }
     }
   }
+
+  {
+    Dali::Mutex::ScopedLock lock( mMutex );
+
+    auto triggeredHandler = std::find( mTriggeredHandlers.begin(), mTriggeredHandlers.end(), &handler );
+    if( triggeredHandler != mTriggeredHandlers.end() )
+    {
+      mTriggeredHandlers.erase( triggeredHandler );
+    }
+  }
 }
 
 void TizenVectorAnimationManager::TriggerEvent( TizenVectorAnimationEventHandler& handler )
@@ -93,16 +103,23 @@ void TizenVectorAnimationManager::Process()
   OnEventTriggered();
 }
 
+// This function is called in the main thread.
 void TizenVectorAnimationManager::OnEventTriggered()
 {
-  Dali::Mutex::ScopedLock lock( mMutex );
+  std::vector< TizenVectorAnimationEventHandler* > handlers;
 
-  for( auto&& iter : mTriggeredHandlers )
   {
-    iter->NotifyEvent();
+    Dali::Mutex::ScopedLock lock( mMutex );
+
+    // Copy the list to the local variable and clear
+    handlers = mTriggeredHandlers;
+    mTriggeredHandlers.clear();
   }
 
-  mTriggeredHandlers.clear();
+  for( auto&& iter : handlers )
+  {
+    iter->NotifyEvent();
+  }
 }
 
 } // namespace Plugin
index 70719c0..e5e92f0 100755 (executable)
@@ -104,7 +104,7 @@ bool TizenVectorAnimationRenderer::Initialize( const std::string& url )
 
   TizenVectorAnimationManager::Get().AddEventHandler( *this );
 
-  DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::Initialize: file [%s] [%p]\n", url.c_str(), this );
+  DALI_LOG_ERROR( "TizenVectorAnimationRenderer::Initialize: file [%s] [%p]\n", url.c_str(), this );
 
   return true;
 }
@@ -130,7 +130,7 @@ void TizenVectorAnimationRenderer::SetRenderer( Renderer renderer )
     SetShader();
   }
 
-  DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::SetRenderer [%p]\n", this );
+  DALI_LOG_ERROR( "TizenVectorAnimationRenderer::SetRenderer [%p]\n", this );
 }
 
 void TizenVectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
@@ -139,7 +139,7 @@ void TizenVectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
 
   if( mWidth == width && mHeight == height )
   {
-    DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::SetSize: Same size (%d, %d) [%p]\n", mWidth, mHeight, this );
+    DALI_LOG_ERROR( "TizenVectorAnimationRenderer::SetSize: Same size (%d, %d) [%p]\n", mWidth, mHeight, this );
     return;
   }
 
@@ -159,7 +159,7 @@ void TizenVectorAnimationRenderer::SetSize( uint32_t width, uint32_t height )
 
   mResourceReady = false;
 
-  DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::SetSize: width = %d, height = %d [%p]\n", mWidth, mHeight, this );
+  DALI_LOG_ERROR( "TizenVectorAnimationRenderer::SetSize: width = %d, height = %d [%p]\n", mWidth, mHeight, this );
 }
 
 bool TizenVectorAnimationRenderer::Render( uint32_t frameNumber )
@@ -229,9 +229,11 @@ bool TizenVectorAnimationRenderer::Render( uint32_t frameNumber )
 
       TizenVectorAnimationManager::Get().TriggerEvent( *this );
 
-      DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::Render: Resource ready [current = %d] [%p]\n", frameNumber, this );
+      DALI_LOG_ERROR( "TizenVectorAnimationRenderer::Render: Resource ready [current = %d] [%p]\n", frameNumber, this );
     }
 
+    DALI_LOG_ERROR( "TizenVectorAnimationRenderer::Render: current = %d [%p]\n", frameNumber, this );
+
     return true;
   }
 
@@ -253,7 +255,7 @@ void TizenVectorAnimationRenderer::GetDefaultSize( uint32_t& width, uint32_t& he
   width = mDefaultWidth;
   height = mDefaultHeight;
 
-  DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::GetDefaultSize: width = %d, height = %d [%p]\n", width, height, this );
+  DALI_LOG_ERROR( "TizenVectorAnimationRenderer::GetDefaultSize: width = %d, height = %d [%p]\n", width, height, this );
 }
 
 void TizenVectorAnimationRenderer::GetLayerInfo( Property::Map& map ) const
@@ -282,7 +284,7 @@ void TizenVectorAnimationRenderer::NotifyEvent()
 
   if( mResourceReadyTriggered )
   {
-    DALI_LOG_RELEASE_INFO( "TizenVectorAnimationRenderer::NotifyEvent: Set Texture [%p]\n", this );
+    DALI_LOG_ERROR( "TizenVectorAnimationRenderer::NotifyEvent: Set Texture [%p]\n", this );
 
     // Set texture
     if( mRenderer )