/*
- * 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.
} // unnamed namespace
std::unique_ptr<RiveAnimationManager> RiveAnimationManager::mInstance = nullptr;
-std::once_flag RiveAnimationManager::mOnceFlag;
+std::once_flag RiveAnimationManager::mOnceFlag;
RiveAnimationManager& RiveAnimationManager::GetInstance()
{
RiveAnimationManager::~RiveAnimationManager()
{
+ for(auto&& iter : mEventCallbacks)
+ {
+ delete iter;
+ }
mEventCallbacks.clear();
if(mProcessorRegistered)
void RiveAnimationManager::RegisterEventCallback(CallbackBase* callback)
{
- mEventCallbacks.emplace_back(std::unique_ptr<Dali::CallbackBase>(callback));
+ mEventCallbacks.push_back(callback);
if(!mProcessorRegistered)
{
void RiveAnimationManager::UnregisterEventCallback(CallbackBase* callback)
{
- auto iter = std::find_if(mEventCallbacks.begin(),
- mEventCallbacks.end(),
- [callback](const std::unique_ptr<CallbackBase>& element) {
- return element.get() == callback;
- });
+ auto iter = std::find(mEventCallbacks.begin(), mEventCallbacks.end(), callback);
if(iter != mEventCallbacks.end())
{
mEventCallbacks.erase(iter);
for(auto&& iter : mEventCallbacks)
{
CallbackBase::Execute(*iter);
+ delete iter;
}
mEventCallbacks.clear();
} // namespace Internal
-} // namespace Extension
+} // namespace Toolkit
} // namespace Dali
#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.
static std::unique_ptr<RiveAnimationManager> mInstance;
static std::once_flag mOnceFlag;
- std::vector<std::unique_ptr<CallbackBase>> mEventCallbacks;
- std::vector<LifecycleObserver*> mLifecycleObservers;
- std::unique_ptr<RiveAnimationThread> mRiveAnimationThread;
- bool mProcessorRegistered;
+ std::vector<CallbackBase*> mEventCallbacks;
+ std::vector<LifecycleObserver*> mLifecycleObservers;
+ std::unique_ptr<RiveAnimationThread> mRiveAnimationThread;
+ bool mProcessorRegistered;
};
} // namespace Internal
/*
- * 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.
if(mEventCallback)
{
riveAnimationManager.UnregisterEventCallback(mEventCallback);
- mEventCallback = nullptr;
}
// Finalize animation task and disconnect the signal in the main thread