@@ -42,6 +42,10 @@ namespace godot {
4242thread_local const StringName *Wrapped::_constructing_extension_class_name = nullptr ;
4343thread_local const GDExtensionInstanceBindingCallbacks *Wrapped::_constructing_class_binding_callbacks = nullptr ;
4444
45+ #ifdef HOT_RELOAD_ENABLED
46+ thread_local GDExtensionObjectPtr Wrapped::_constructing_recreate_owner = nullptr ;
47+ #endif
48+
4549const StringName *Wrapped::_get_extension_class_name () {
4650 return nullptr ;
4751}
@@ -55,25 +59,14 @@ void Wrapped::_postinitialize() {
5559
5660Wrapped::Wrapped (const StringName p_godot_class) {
5761#ifdef HOT_RELOAD_ENABLED
58- if (unlikely (Wrapped::recreate_instance)) {
59- RecreateInstance *recreate_data = Wrapped::recreate_instance;
60- RecreateInstance *previous = nullptr ;
61- while (recreate_data) {
62- if (recreate_data->wrapper == this ) {
63- _owner = recreate_data->owner ;
64- if (previous) {
65- previous->next = recreate_data->next ;
66- } else {
67- Wrapped::recreate_instance = recreate_data->next ;
68- }
69- return ;
70- }
71- previous = recreate_data;
72- recreate_data = recreate_data->next ;
73- }
74- }
62+ if (unlikely (Wrapped::_constructing_recreate_owner)) {
63+ _owner = Wrapped::_constructing_recreate_owner;
64+ Wrapped::_constructing_recreate_owner = nullptr ;
65+ } else
7566#endif
76- _owner = godot::internal::gdextension_interface_classdb_construct_object (reinterpret_cast <GDExtensionConstStringNamePtr>(p_godot_class._native_ptr ()));
67+ {
68+ _owner = godot::internal::gdextension_interface_classdb_construct_object (reinterpret_cast <GDExtensionConstStringNamePtr>(p_godot_class._native_ptr ()));
69+ }
7770
7871 if (_constructing_extension_class_name) {
7972 godot::internal::gdextension_interface_object_set_instance (_owner, reinterpret_cast <GDExtensionConstStringNamePtr>(_constructing_extension_class_name), this );
0 commit comments