mirror of
https://github.com/godotengine/godot.git
synced 2025-10-22 09:23:40 +00:00
fixes #46839, ensure library_classes is cleared and free funcs are called
Co-authored-by: toasteater <48371905+toasteater@users.noreply.github.com>
Co-authored-by: Jan Haller <bromeon@gmail.com>
(cherry picked from commit 58fa4973f6
)
This commit is contained in:
parent
7447c3b76c
commit
2bf0b2996a
1 changed files with 34 additions and 0 deletions
|
@ -1502,6 +1502,40 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
|
|||
if (S->get().size() == 0) {
|
||||
library_script_users.erase(S);
|
||||
|
||||
Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.find(script->lib_path);
|
||||
if (L) {
|
||||
Map<StringName, NativeScriptDesc> classes = L->get();
|
||||
|
||||
for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) {
|
||||
// free property stuff first
|
||||
for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) {
|
||||
if (P.get().getter.free_func) {
|
||||
P.get().getter.free_func(P.get().getter.method_data);
|
||||
}
|
||||
|
||||
if (P.get().setter.free_func) {
|
||||
P.get().setter.free_func(P.get().setter.method_data);
|
||||
}
|
||||
}
|
||||
|
||||
// free method stuff
|
||||
for (Map<StringName, NativeScriptDesc::Method>::Element *M = C->get().methods.front(); M; M = M->next()) {
|
||||
if (M->get().method.free_func) {
|
||||
M->get().method.free_func(M->get().method.method_data);
|
||||
}
|
||||
}
|
||||
|
||||
// free constructor/destructor
|
||||
if (C->get().create_func.free_func) {
|
||||
C->get().create_func.free_func(C->get().create_func.method_data);
|
||||
}
|
||||
|
||||
if (C->get().destroy_func.free_func) {
|
||||
C->get().destroy_func.free_func(C->get().destroy_func.method_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Ref<GDNative> >::Element *G = library_gdnatives.find(script->lib_path);
|
||||
if (G && G->get()->get_library()->is_reloadable()) {
|
||||
G->get()->terminate();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue