Removes the gdnative library when no script (gdns) references it any longer. This enables hot reload for gdnative.

(cherry picked from commit cc5d8bb5adf46aef63828fb23095589e51cca783)
This commit is contained in:
geekrelief 2020-12-23 06:23:41 -08:00 committed by Rémi Verschelde
parent 7ede2f36fe
commit 311ca0c6f2
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -1528,6 +1528,12 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) {
S->get().erase(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()->terminate();
library_gdnatives.erase(G);
}
}
}
#ifndef NO_THREADS