Explorar el Código

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

geekrelief hace 4 años
padre
commit
cc5d8bb5ad
Se han modificado 1 ficheros con 6 adiciones y 0 borrados
  1. 6 0
      modules/gdnative/nativescript/nativescript.cpp

+ 6 - 0
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