diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-01-18 14:25:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-18 14:25:26 +0100 |
commit | 0550c7d9a78e71c6c21f90b8c9c3ccbccbe65bf1 (patch) | |
tree | c7fe20c5126c36f18e8433ac2533a227435ae49f | |
parent | 9d45b719d4ed1f50c93f3234b31233ae5039987c (diff) | |
parent | 9b96f8737724c481066d2e1bc2280c1de42ef136 (diff) |
Merge pull request #15836 from karroffel/gdnative-more-fixes-hopefully
[GDNative] fix #15723
-rw-r--r-- | modules/gdnative/nativescript/nativescript.cpp | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index cff5d9c9bd..2216be0257 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -798,11 +798,33 @@ NativeScriptLanguage *NativeScriptLanguage::singleton; void NativeScriptLanguage::_unload_stuff(bool p_reload) { for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) { - if (p_reload && library_gdnatives[L->key()].is_valid() && !library_gdnatives[L->key()]->get_library()->is_reloadable()) { - continue; + String lib_path = L->key(); + Map<StringName, NativeScriptDesc> classes = L->get(); + + if (p_reload) { + + Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path); + Ref<GDNative> gdn; + + if (E) { + gdn = E->get(); + } + + bool should_reload = false; + + if (gdn.is_valid()) { + Ref<GDNativeLibrary> lib = gdn->get_library(); + if (lib.is_valid()) { + should_reload = lib->is_reloadable(); + } + } + + if (!should_reload) { + continue; + } } - for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) { + for (Map<StringName, NativeScriptDesc>::Element *C = classes.front(); C; C = C->next()) { // free property stuff first for (OrderedHashMap<StringName, NativeScriptDesc::Property>::Element P = C->get().properties.front(); P; P = P.next()) { @@ -1063,6 +1085,11 @@ void NativeScriptLanguage::unregister_script(NativeScript *script) { void NativeScriptLanguage::call_libraries_cb(const StringName &name) { // library_gdnatives is modified only from the main thread, so it's safe not to use mutex here for (Map<String, Ref<GDNative> >::Element *L = library_gdnatives.front(); L; L = L->next()) { + + if (L->get().is_null()) { + continue; + } + if (L->get()->is_initialized()) { void *proc_ptr; @@ -1125,6 +1152,10 @@ void NativeReloadNode::_notification(int p_what) { Ref<GDNative> gdn = L->get(); + if (gdn.is_null()) { + continue; + } + if (!gdn->get_library()->is_reloadable()) { continue; } @@ -1149,6 +1180,10 @@ void NativeReloadNode::_notification(int p_what) { Ref<GDNative> gdn = L->get(); + if (gdn.is_null()) { + continue; + } + if (!gdn->get_library()->is_reloadable()) { continue; } |