summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-01-26 15:52:33 +0100
committerGitHub <noreply@github.com>2021-01-26 15:52:33 +0100
commitf7dd6975fb8074c7a4a46b400d8ca0caff09675f (patch)
tree56b8e8a8c0205c710da46dfbb5b43bd10e65c5c3
parent6bea3015330473794ae0bc25d6d25f3d0bd3ead4 (diff)
parentcc5d8bb5adf46aef63828fb23095589e51cca783 (diff)
Merge pull request #44617 from geekrelief/gdnative_unload
free library when no nativescripts reference it
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index e08961564d..944f4f052c 100644
--- a/modules/gdnative/nativescript/nativescript.cpp
+++ b/modules/gdnative/nativescript/nativescript.cpp
@@ -1724,6 +1724,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