소스 검색

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

(cherry picked from commit cc5d8bb5adf46aef63828fb23095589e51cca783)
geekrelief 4 년 전
부모
커밋
311ca0c6f2
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      modules/gdnative/nativescript/nativescript.cpp

+ 6 - 0
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<String, Ref<GDNative> >::Element *G = library_gdnatives.find(script->lib_path);
+			if (G) {
+				G->get()->terminate();
+				library_gdnatives.erase(G);
+			}
 		}
 	}
 #ifndef NO_THREADS