From 649038c5a093f3548a224c3055d9b1bdb43d4b4c Mon Sep 17 00:00:00 2001 From: "Eunki, Hong" Date: Mon, 7 Aug 2023 10:50:02 +0900 Subject: [PATCH] Revert "(Rive) Make rasterize callback as unique_ptr" This reverts commit f5a6f64dcdebc4dc6cc807dfcf4b560c53e9bbba. --- .../rive-animation-view/rive-animation-manager.cpp | 19 ++++++++++--------- .../rive-animation-view/rive-animation-manager.h | 10 +++++----- .../rive-animation-view/rive-animation-view-impl.cpp | 3 +-- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dali-extension/internal/rive-animation-view/rive-animation-manager.cpp b/dali-extension/internal/rive-animation-view/rive-animation-manager.cpp index cbf5c99..545e8aa 100644 --- a/dali-extension/internal/rive-animation-view/rive-animation-manager.cpp +++ b/dali-extension/internal/rive-animation-view/rive-animation-manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ Debug::Filter* gRiveAnimationLogFilter = Debug::Filter::New(Debug::NoLogging, fa } // unnamed namespace std::unique_ptr RiveAnimationManager::mInstance = nullptr; -std::once_flag RiveAnimationManager::mOnceFlag; +std::once_flag RiveAnimationManager::mOnceFlag; RiveAnimationManager& RiveAnimationManager::GetInstance() { @@ -60,6 +60,10 @@ RiveAnimationManager::RiveAnimationManager() RiveAnimationManager::~RiveAnimationManager() { + for(auto&& iter : mEventCallbacks) + { + delete iter; + } mEventCallbacks.clear(); if(mProcessorRegistered) @@ -100,7 +104,7 @@ RiveAnimationThread& RiveAnimationManager::GetRiveAnimationThread() void RiveAnimationManager::RegisterEventCallback(CallbackBase* callback) { - mEventCallbacks.emplace_back(std::unique_ptr(callback)); + mEventCallbacks.push_back(callback); if(!mProcessorRegistered) { @@ -111,11 +115,7 @@ void RiveAnimationManager::RegisterEventCallback(CallbackBase* callback) void RiveAnimationManager::UnregisterEventCallback(CallbackBase* callback) { - auto iter = std::find_if(mEventCallbacks.begin(), - mEventCallbacks.end(), - [callback](const std::unique_ptr& element) { - return element.get() == callback; - }); + auto iter = std::find(mEventCallbacks.begin(), mEventCallbacks.end(), callback); if(iter != mEventCallbacks.end()) { mEventCallbacks.erase(iter); @@ -136,6 +136,7 @@ void RiveAnimationManager::Process(bool postProcessor) for(auto&& iter : mEventCallbacks) { CallbackBase::Execute(*iter); + delete iter; } mEventCallbacks.clear(); @@ -145,6 +146,6 @@ void RiveAnimationManager::Process(bool postProcessor) } // namespace Internal -} // namespace Extension +} // namespace Toolkit } // namespace Dali diff --git a/dali-extension/internal/rive-animation-view/rive-animation-manager.h b/dali-extension/internal/rive-animation-view/rive-animation-manager.h index ba08c60..b5a4811 100644 --- a/dali-extension/internal/rive-animation-view/rive-animation-manager.h +++ b/dali-extension/internal/rive-animation-view/rive-animation-manager.h @@ -2,7 +2,7 @@ #define DALI_EXTENSION_INTERNAL_RIVE_ANIMATION_MANAGER_H /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -110,10 +110,10 @@ private: static std::unique_ptr mInstance; static std::once_flag mOnceFlag; - std::vector> mEventCallbacks; - std::vector mLifecycleObservers; - std::unique_ptr mRiveAnimationThread; - bool mProcessorRegistered; + std::vector mEventCallbacks; + std::vector mLifecycleObservers; + std::unique_ptr mRiveAnimationThread; + bool mProcessorRegistered; }; } // namespace Internal diff --git a/dali-extension/internal/rive-animation-view/rive-animation-view-impl.cpp b/dali-extension/internal/rive-animation-view/rive-animation-view-impl.cpp index 83c5f89..4df35eb 100644 --- a/dali-extension/internal/rive-animation-view/rive-animation-view-impl.cpp +++ b/dali-extension/internal/rive-animation-view/rive-animation-view-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,7 +124,6 @@ RiveAnimationView::~RiveAnimationView() if(mEventCallback) { riveAnimationManager.UnregisterEventCallback(mEventCallback); - mEventCallback = nullptr; } // Finalize animation task and disconnect the signal in the main thread -- 2.7.4