From 8e047568266c9b9709223bb0d9d40f0ab8f86333 Mon Sep 17 00:00:00 2001 From: pssea Date: Wed, 16 Jun 2021 15:47:22 +0800 Subject: [PATCH] Description: fix animator stop in other animator and animator callback last frame issue IssueNo: #I3VSVG Feature or Bugfix: Feature Binary Source:No Signed-off-by: lizhiqi --- frameworks/animator/animator.cpp | 4 ++++ frameworks/animator/animator_manager.cpp | 9 +++++++-- frameworks/engines/gfx/gfx_engine_manager.cpp | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/frameworks/animator/animator.cpp b/frameworks/animator/animator.cpp index f10d3a4..5d75074 100755 --- a/frameworks/animator/animator.cpp +++ b/frameworks/animator/animator.cpp @@ -61,6 +61,10 @@ void Animator::Run() runTime_ = (UINT32_MAX - elapse > runTime_) ? (runTime_ + elapse) : period_; if (!repeat_ && (runTime_ >= period_)) { + runTime_ = period_; + if (callback_ != nullptr) { + callback_->Callback(view_); + } Stop(); return; } diff --git a/frameworks/animator/animator_manager.cpp b/frameworks/animator/animator_manager.cpp index f2af9c2..fe78324 100644 --- a/frameworks/animator/animator_manager.cpp +++ b/frameworks/animator/animator_manager.cpp @@ -56,7 +56,7 @@ void AnimatorManager::Remove(const Animator* animator) ListNode* pos = list_.Begin(); while (pos != list_.End()) { if (pos->data_ == animator) { - list_.Remove(pos); + pos->data_ = nullptr; return; } pos = pos->next_; @@ -70,10 +70,15 @@ void AnimatorManager::AnimatorTask() while (pos != list_.End()) { animator = pos->data_; - pos = pos->next_; + if (animator == nullptr) { + // clean up animator list + pos = list_.Remove(pos); + continue; + } if (animator->GetState() == Animator::START) { animator->Run(); } + pos = pos->next_; } } } // namespace OHOS diff --git a/frameworks/engines/gfx/gfx_engine_manager.cpp b/frameworks/engines/gfx/gfx_engine_manager.cpp index 0f45a06..3d13665 100644 --- a/frameworks/engines/gfx/gfx_engine_manager.cpp +++ b/frameworks/engines/gfx/gfx_engine_manager.cpp @@ -14,6 +14,9 @@ */ #include "engines/gfx/gfx_engine_manager.h" + +#include + #include "draw/draw_arc.h" #include "draw/draw_curve.h" #include "draw/draw_line.h" -- GitLab