/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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)
{
mFactoryCache.GetVectorAnimationManager().UnregisterEventCallback(mEventCallback);
+ mEventCallback = nullptr;
}
// Finalize animation task and disconnect the signal in the main thread
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
VectorAnimationManager::~VectorAnimationManager()
{
- for(auto&& iter : mEventCallbacks)
- {
- delete iter;
- }
mEventCallbacks.clear();
if(mProcessorRegistered)
void VectorAnimationManager::RegisterEventCallback(CallbackBase* callback)
{
- mEventCallbacks.push_back(callback);
+ mEventCallbacks.emplace_back(std::unique_ptr<Dali::CallbackBase>(callback));
if(!mProcessorRegistered)
{
void VectorAnimationManager::UnregisterEventCallback(CallbackBase* callback)
{
- auto iter = std::find(mEventCallbacks.begin(), mEventCallbacks.end(), callback);
+ auto iter = std::find_if(mEventCallbacks.begin(),
+ mEventCallbacks.end(),
+ [callback](const std::unique_ptr<CallbackBase>& element) {
+ return element.get() == callback;
+ });
if(iter != mEventCallbacks.end())
{
mEventCallbacks.erase(iter);
for(auto&& iter : mEventCallbacks)
{
CallbackBase::Execute(*iter);
- delete iter;
}
mEventCallbacks.clear();
#define DALI_TOOLKIT_INTERNAL_VECTOR_ANIMATION_MANAGER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
VectorAnimationManager& operator=(const VectorAnimationManager& manager) = delete;
private:
- std::vector<CallbackBase*> mEventCallbacks;
- std::vector<LifecycleObserver*> mLifecycleObservers;
- std::unique_ptr<VectorAnimationThread> mVectorAnimationThread;
- bool mProcessorRegistered;
+ std::vector<std::unique_ptr<CallbackBase>> mEventCallbacks;
+ std::vector<LifecycleObserver*> mLifecycleObservers;
+ std::unique_ptr<VectorAnimationThread> mVectorAnimationThread;
+ bool mProcessorRegistered;
};
} // namespace Internal