diff options
author | David Snopek <dsnopek@gmail.com> | 2024-10-17 16:05:02 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-17 16:05:02 +0200 |
commit | a98d41f62bdb8b7aa903e8e37c1faa48fe8fdae8 (patch) | |
tree | 4c2a7bd537450ab1e394a4f5653634c030d3dc48 /src/classes/wrapped.cpp | |
parent | 96675a814b9038b7da57607c34b8e7e69b8c1678 (diff) | |
parent | cb543c192aef18b3e9b9d2c9f2ba770a4e574ad0 (diff) | |
download | redot-cpp-a98d41f62bdb8b7aa903e8e37c1faa48fe8fdae8.tar.gz |
Merge pull request #1590 from dsnopek/reload-instance-bindings
Correctly set instance bindings on reload
Diffstat (limited to 'src/classes/wrapped.cpp')
-rw-r--r-- | src/classes/wrapped.cpp | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp index ffca4f9..d397d46 100644 --- a/src/classes/wrapped.cpp +++ b/src/classes/wrapped.cpp @@ -42,6 +42,10 @@ namespace godot { thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr; thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr; +#ifdef HOT_RELOAD_ENABLED +thread_local GDExtensionObjectPtr Wrapped::_constructing_recreate_owner = nullptr; +#endif + const StringName *Wrapped::_get_extension_class_name() { return nullptr; } @@ -55,25 +59,14 @@ void Wrapped::_postinitialize() { Wrapped::Wrapped(const StringName p_godot_class) { #ifdef HOT_RELOAD_ENABLED - if (unlikely(Wrapped::recreate_instance)) { - RecreateInstance *recreate_data = Wrapped::recreate_instance; - RecreateInstance *previous = nullptr; - while (recreate_data) { - if (recreate_data->wrapper == this) { - _owner = recreate_data->owner; - if (previous) { - previous->next = recreate_data->next; - } else { - Wrapped::recreate_instance = recreate_data->next; - } - return; - } - previous = recreate_data; - recreate_data = recreate_data->next; - } - } + if (unlikely(Wrapped::_constructing_recreate_owner)) { + _owner = Wrapped::_constructing_recreate_owner; + Wrapped::_constructing_recreate_owner = nullptr; + } else #endif - _owner = godot::internal::gdextension_interface_classdb_construct_object(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr())); + { + _owner = godot::internal::gdextension_interface_classdb_construct_object(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr())); + } if (_constructing_extension_class_name) { godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(_constructing_extension_class_name), this); |