From bb5173a1c393367684bab040d08db3266d746018 Mon Sep 17 00:00:00 2001 From: bodymovin Date: Mon, 9 Dec 2024 22:35:00 +0000 Subject: [PATCH] Nnnn data bind fixes part 3 This PR is mostly about handling pointers between dart and rive_native. All data binding classes are now wrapped in a reference counted class to make sure that there are no unhandled pointers. Diffs= d3f6a49778 Nnnn data bind fixes part 3 (#8663) Co-authored-by: hernan --- .rive_head | 2 +- include/rive/viewmodel/viewmodel_instance.hpp | 1 + include/rive/viewmodel/viewmodel_instance_viewmodel.hpp | 1 + src/viewmodel/viewmodel_instance.cpp | 8 ++++++++ src/viewmodel/viewmodel_instance_viewmodel.cpp | 5 +++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.rive_head b/.rive_head index ddb15eae..014d8d70 100644 --- a/.rive_head +++ b/.rive_head @@ -1 +1 @@ -baf832a6ce3135bc7f8f8b5cc3695f024610b744 +d3f6a49778aa6ce7408aecededeb1afc1bf33e6e diff --git a/include/rive/viewmodel/viewmodel_instance.hpp b/include/rive/viewmodel/viewmodel_instance.hpp index 53d5d044..70f898ef 100644 --- a/include/rive/viewmodel/viewmodel_instance.hpp +++ b/include/rive/viewmodel/viewmodel_instance.hpp @@ -14,6 +14,7 @@ class ViewModelInstance : public ViewModelInstanceBase ViewModel* m_ViewModel; public: + ~ViewModelInstance(); void addValue(ViewModelInstanceValue* value); ViewModelInstanceValue* propertyValue(const uint32_t id); ViewModelInstanceValue* propertyValue(const std::string& name); diff --git a/include/rive/viewmodel/viewmodel_instance_viewmodel.hpp b/include/rive/viewmodel/viewmodel_instance_viewmodel.hpp index 360e56a4..e44c2ee7 100644 --- a/include/rive/viewmodel/viewmodel_instance_viewmodel.hpp +++ b/include/rive/viewmodel/viewmodel_instance_viewmodel.hpp @@ -11,6 +11,7 @@ class ViewModelInstanceViewModel : public ViewModelInstanceViewModelBase ViewModelInstance* m_referenceViewModelInstance; public: + ~ViewModelInstanceViewModel(); void referenceViewModelInstance(ViewModelInstance* value) { m_referenceViewModelInstance = value; diff --git a/src/viewmodel/viewmodel_instance.cpp b/src/viewmodel/viewmodel_instance.cpp index bf05c352..51457a71 100644 --- a/src/viewmodel/viewmodel_instance.cpp +++ b/src/viewmodel/viewmodel_instance.cpp @@ -11,6 +11,14 @@ using namespace rive; +ViewModelInstance::~ViewModelInstance() +{ + for (auto value : m_PropertyValues) + { + delete value; + } +} + void ViewModelInstance::addValue(ViewModelInstanceValue* value) { m_PropertyValues.push_back(value); diff --git a/src/viewmodel/viewmodel_instance_viewmodel.cpp b/src/viewmodel/viewmodel_instance_viewmodel.cpp index 7630112e..9fa8899a 100644 --- a/src/viewmodel/viewmodel_instance_viewmodel.cpp +++ b/src/viewmodel/viewmodel_instance_viewmodel.cpp @@ -6,6 +6,11 @@ using namespace rive; +ViewModelInstanceViewModel::~ViewModelInstanceViewModel() +{ + delete m_referenceViewModelInstance; +} + void ViewModelInstanceViewModel::setRoot(ViewModelInstance* value) { Super::setRoot(value);