From 311ca0c6f23784dfa831d8f058a335f698dcc5ea Mon Sep 17 00:00:00 2001 From: geekrelief Date: Wed, 23 Dec 2020 06:23:41 -0800 Subject: [PATCH] Removes the gdnative library when no script (gdns) references it any longer. This enables hot reload for gdnative. (cherry picked from commit cc5d8bb5adf46aef63828fb23095589e51cca783) --- modules/gdnative/nativescript/nativescript.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index bf2a8b87036..fd7ba3d30f9 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -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 >::Element *G = library_gdnatives.find(script->lib_path); + if (G) { + G->get()->terminate(); + library_gdnatives.erase(G); + } } } #ifndef NO_THREADS