Skip to content

Commit

Permalink
Nnnn data bind fixes part 3
Browse files Browse the repository at this point in the history
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 <hernan@rive.app>
  • Loading branch information
bodymovin and bodymovin committed Dec 9, 2024
1 parent 01f1f18 commit bb5173a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
baf832a6ce3135bc7f8f8b5cc3695f024610b744
d3f6a49778aa6ce7408aecededeb1afc1bf33e6e
1 change: 1 addition & 0 deletions include/rive/viewmodel/viewmodel_instance.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions include/rive/viewmodel/viewmodel_instance_viewmodel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ViewModelInstanceViewModel : public ViewModelInstanceViewModelBase
ViewModelInstance* m_referenceViewModelInstance;

public:
~ViewModelInstanceViewModel();
void referenceViewModelInstance(ViewModelInstance* value)
{
m_referenceViewModelInstance = value;
Expand Down
8 changes: 8 additions & 0 deletions src/viewmodel/viewmodel_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions src/viewmodel/viewmodel_instance_viewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

using namespace rive;

ViewModelInstanceViewModel::~ViewModelInstanceViewModel()
{
delete m_referenceViewModelInstance;
}

void ViewModelInstanceViewModel::setRoot(ViewModelInstance* value)
{
Super::setRoot(value);
Expand Down

0 comments on commit bb5173a

Please sign in to comment.