summaryrefslogtreecommitdiffstats
path: root/test/src/example.cpp
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-07-29 01:20:07 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2022-07-29 02:36:12 +0200
commit78cbae910d1c75a942673440ad96587e4e3baba8 (patch)
tree2fe386712b46b169decc9293ce22f354022d271e /test/src/example.cpp
parent8d4de1b5379632758ff9d419e6d5bb186daed401 (diff)
downloadredot-cpp-78cbae910d1c75a942673440ad96587e4e3baba8.tar.gz
Fix "_instance_bindings != nullptr" for Wrapped objects.
This is an attempt to make the lifecycle of wrapped objects clearer. Godot keeps track of bindings' userdata for each object it creates. This allows allocating the memory of the wrapper only once per object even if that object is passed multiple times between binding code and godot code. The binding information is composed of multiple functions, this includes a callback for when the userdata is to be allocated (called once) and for when the userdata is to be deallocated (again, called once). When allocating data with "memnew" we set the object bindings during the postinitialize phase, but surely we shouldn't do that when allocating the userdata as a result of bindings callback themselves. Additionally, since we let Godot handle (and track) raw memory allocation and de-allocation, we need to manually call the deconstructor of the wrapper class during the free callback, to ensure that its non-trivial members are correctly de-initialized.
Diffstat (limited to 'test/src/example.cpp')
0 files changed, 0 insertions, 0 deletions