summaryrefslogtreecommitdiffstats
path: root/src/classes
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2023-08-04 11:02:57 -0500
committerDavid Snopek <dsnopek@gmail.com>2023-09-25 22:13:33 -0500
commitdf849651d9d71e3b901fe386a6752aec368c7206 (patch)
treefc6e5fabafb682aeba91c124d7c4beebb5c9c4ef /src/classes
parentc44c3d5ebf9826214efc971f0cbe047789af2575 (diff)
downloadredot-cpp-df849651d9d71e3b901fe386a6752aec368c7206.tar.gz
Changes necessary for hot reload to work
Diffstat (limited to 'src/classes')
-rw-r--r--src/classes/wrapped.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/classes/wrapped.cpp b/src/classes/wrapped.cpp
index 1e9239c..5b425c7 100644
--- a/src/classes/wrapped.cpp
+++ b/src/classes/wrapped.cpp
@@ -49,6 +49,25 @@ 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;
+ }
+ }
+#endif
_owner = godot::internal::gdextension_interface_classdb_construct_object(reinterpret_cast<GDExtensionConstStringNamePtr>(p_godot_class._native_ptr()));
}