summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorkarroffel <therzog@mail.de>2018-01-18 12:04:34 +0100
committerkarroffel <therzog@mail.de>2018-01-18 12:04:34 +0100
commit9b96f8737724c481066d2e1bc2280c1de42ef136 (patch)
tree347374e5569934eb04bb72c9fcea5585a2426752 /modules
parent945248052cd35df2dcc2408fdd48f3ea511a0562 (diff)
[GDNative] fix #15723
Diffstat (limited to 'modules')
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp41
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;
}