diff options
author | Thomas Herzog <thomas.herzog@mail.com> | 2017-07-25 18:42:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-25 18:42:18 +0200 |
commit | 497411aa124f665e6f89bc6137c65fbd106a7859 (patch) | |
tree | dc1071f9e51d8a5cf6dbf186a040166d7ea7d362 | |
parent | 47b2455a627f823e300c9ab1c1fd39dcd65607a7 (diff) | |
parent | cdf1212bee6ce3f09d025596926df2005e7f3304 (diff) |
Merge pull request #9844 from karroffel/nativescript-double-init-fix
[NativeScript] fix double initialization in editor
-rw-r--r-- | modules/nativescript/nativescript.cpp | 10 | ||||
-rw-r--r-- | modules/nativescript/nativescript.h | 2 |
2 files changed, 10 insertions, 2 deletions
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp index 493f21d75e..541fe951e4 100644 --- a/modules/nativescript/nativescript.cpp +++ b/modules/nativescript/nativescript.cpp @@ -958,7 +958,8 @@ void NativeReloadNode::_notification(int p_what) { switch (p_what) { case MainLoop::NOTIFICATION_WM_FOCUS_OUT: { - print_line("unload"); + if (unloaded) + break; NSL->_unload_stuff(); for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -967,11 +968,14 @@ void NativeReloadNode::_notification(int p_what) { NSL->library_classes.erase(L->key()); } + unloaded = true; + } break; case MainLoop::NOTIFICATION_WM_FOCUS_IN: { - print_line("load"); + if (!unloaded) + break; Set<StringName> libs_to_remove; @@ -1010,6 +1014,8 @@ void NativeReloadNode::_notification(int p_what) { } } + unloaded = false; + for (Set<StringName>::Element *R = libs_to_remove.front(); R; R = R->next()) { NSL->library_gdnatives.erase(R->get()); } diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h index 5702ba2e8d..bc7a6e3ed6 100644 --- a/modules/nativescript/nativescript.h +++ b/modules/nativescript/nativescript.h @@ -259,6 +259,8 @@ inline NativeScriptDesc *NativeScript::get_script_desc() const { class NativeReloadNode : public Node { GDCLASS(NativeReloadNode, Node) + bool unloaded = false; + public: static void _bind_methods(); void _notification(int p_what); |