Only cleanup meta data if GDNative library is reloadable and we're about to unload it
This commit is contained in:
parent
f4b82814f8
commit
81131bd844
@ -1727,6 +1727,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
|
||||
if (S->get().size() == 0) {
|
||||
library_script_users.erase(S);
|
||||
|
||||
Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path);
|
||||
if (G && G->get()->get_library()->is_reloadable()) {
|
||||
// ONLY if the library is marked as reloadable, and no more instances of its scripts exist do we unload the library
|
||||
|
||||
// First remove meta data related to the library
|
||||
Map<String, Map<StringName, NativeScriptDesc>>::Element *L = library_classes.find(script->lib_path);
|
||||
if (L) {
|
||||
Map<StringName, NativeScriptDesc> classes = L->get();
|
||||
@ -1763,8 +1768,7 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
|
||||
library_classes.erase(script->lib_path);
|
||||
}
|
||||
|
||||
Map<String, Ref<GDNative>>::Element *G = library_gdnatives.find(script->lib_path);
|
||||
if (G && G->get()->get_library()->is_reloadable()) {
|
||||
// now unload the library
|
||||
G->get()->terminate();
|
||||
library_gdnatives.erase(G);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user