summaryrefslogtreecommitdiffstats
path: root/src
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
parentc44c3d5ebf9826214efc971f0cbe047789af2575 (diff)
downloadredot-cpp-df849651d9d71e3b901fe386a6752aec368c7206.tar.gz
Changes necessary for hot reload to work
Diffstat (limited to 'src')
-rw-r--r--src/classes/wrapped.cpp19
-rw-r--r--src/core/class_db.cpp3
2 files changed, 22 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()));
}
diff --git a/src/core/class_db.cpp b/src/core/class_db.cpp
index 9aaacef..7219a79 100644
--- a/src/core/class_db.cpp
+++ b/src/core/class_db.cpp
@@ -365,6 +365,9 @@ void ClassDB::deinitialize(GDExtensionInitializationLevel p_level) {
for (auto method : cl.method_map) {
memdelete(method.second);
}
+
+ classes.erase(*i);
+ class_register_order.erase((i + 1).base());
}
}