From 0e5b2b16ede012ffc1bddb5e6e3770234eda6032 Mon Sep 17 00:00:00 2001 From: "thomas.herzog" Date: Fri, 22 Mar 2019 11:46:34 +0100 Subject: [PATCH 1/2] [GDNative] remove spam at editor unfocus when using NativeScript --- modules/gdnative/nativescript/nativescript.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 2da9d6bfdc2..509d78d4f27 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -1691,7 +1691,7 @@ void NativeReloadNode::_notification(int p_what) { // since singleton libraries are not unloaded there is no point // in loading them again. - if (!gdn->get_library()->is_singleton()) { + if (gdn->get_library()->is_singleton()) { continue; } From 5fff7f741a8cc18e6f891ddee6f4130f624ece57 Mon Sep 17 00:00:00 2001 From: "thomas.herzog" Date: Fri, 22 Mar 2019 12:54:19 +0100 Subject: [PATCH 2/2] [GDNative] fix NativeScript leak in editor --- .../gdnative/nativescript/nativescript.cpp | 38 +++++++++---------- modules/gdnative/nativescript/nativescript.h | 1 + 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index 509d78d4f27..5cf144d4fe3 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -160,8 +160,10 @@ bool NativeScript::can_instance() const { NativeScriptDesc *script_data = get_script_desc(); #ifdef TOOLS_ENABLED - - return script_data || (!is_tool() && !ScriptServer::is_scripting_enabled()); + // Only valid if this is either a tool script or a "regular" script. + // (so an environment whre scripting is disabled (and not the editor) would not + // create objects). + return script_data && (is_tool() || ScriptServer::is_scripting_enabled()); #else return script_data; #endif @@ -199,25 +201,6 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) { return NULL; } -#ifdef TOOLS_ENABLED - if (!ScriptServer::is_scripting_enabled() && !is_tool()) { - // placeholder for nodes. For tools we want the rool thing. - - PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(NSL, Ref