From f7ad33bbc4acf3b9278a82e815209a88ffeb943a Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Wed, 6 Dec 2023 17:00:55 +0900 Subject: [PATCH] [Tizen] (Vector) Erase all EventThreadCallbacks with same pointer Due to some logical issue, there might be happend that we apply multiple EventThread callback into VectorAnimationThread. And if VectorAnimationTask destructor called, we remove only single callback. If error case occured, EventThread can execute dead callback. Change-Id: I9e3895180916a292bbca838997ae3053ee8799b5 Signed-off-by: Eunki, Hong --- .../visuals/animated-vector-image/vector-animation-task.cpp | 4 ++-- .../visuals/animated-vector-image/vector-animation-thread.cpp | 9 +++------ .../visuals/animated-vector-image/vector-animation-thread.h | 4 ++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index 4bb2471..0c3b3bb 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -118,12 +118,12 @@ void VectorAnimationTask::Finalize() // Release some objects in the main thread if(mAnimationFinishedCallback) { - mVectorAnimationThread.RemoveEventTriggerCallback(mAnimationFinishedCallback.get()); + mVectorAnimationThread.RemoveEventTriggerCallbacks(mAnimationFinishedCallback.get()); mAnimationFinishedCallback.reset(); } if(mLoadCompletedCallback) { - mVectorAnimationThread.RemoveEventTriggerCallback(mLoadCompletedCallback.get()); + mVectorAnimationThread.RemoveEventTriggerCallbacks(mLoadCompletedCallback.get()); mLoadCompletedCallback.reset(); } diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp index 66a9f14..8f70ae3 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.cpp @@ -163,14 +163,11 @@ void VectorAnimationThread::AddEventTriggerCallback(CallbackBase* callback) } } -void VectorAnimationThread::RemoveEventTriggerCallback(CallbackBase* callback) +void VectorAnimationThread::RemoveEventTriggerCallbacks(CallbackBase* callback) { ConditionalWait::ScopedLock lock(mConditionalWait); - auto iter = std::find(mTriggerEventCallbacks.begin(), mTriggerEventCallbacks.end(), callback); - if(iter != mTriggerEventCallbacks.end()) - { - mTriggerEventCallbacks.erase(iter); - } + auto iter = std::remove(mTriggerEventCallbacks.begin(), mTriggerEventCallbacks.end(), callback); + mTriggerEventCallbacks.erase(iter, mTriggerEventCallbacks.end()); } void VectorAnimationThread::Run() diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h index 07537c5..a5108d5 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-thread.h @@ -82,11 +82,11 @@ public: void AddEventTriggerCallback(CallbackBase* callback); /** - * @brief Remove an event trigger callback. + * @brief Remove event trigger callbacks what we added before. * * @param callback The callback to remove */ - void RemoveEventTriggerCallback(CallbackBase* callback); + void RemoveEventTriggerCallbacks(CallbackBase* callback); protected: /** -- 2.7.4