summaryrefslogtreecommitdiff
path: root/modules/gdnative
diff options
context:
space:
mode:
authorThomas Herzog <thomas.herzog@mail.com>2019-03-25 08:07:59 +0100
committerGitHub <noreply@github.com>2019-03-25 08:07:59 +0100
commit81292665d5dcc991d3c9341245b269193329ee22 (patch)
tree6d27f95f6f9e5754443ad5de688187c1bb104452 /modules/gdnative
parente45393482463ddb606bab4f2a78f4a5024cdce7a (diff)
parent5fff7f741a8cc18e6f891ddee6f4130f624ece57 (diff)
Merge pull request #27320 from karroffel/gdnative-terminate-error-print
[GDNative] various NativeScript fixes around editor functionality
Diffstat (limited to 'modules/gdnative')
-rw-r--r--modules/gdnative/nativescript/nativescript.cpp40
-rw-r--r--modules/gdnative/nativescript/nativescript.h1
2 files changed, 19 insertions, 22 deletions
diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp
index 2da9d6bfdc..5cf144d4fe 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<Script>(this), p_this));
- placeholders.insert(sins);
-
- if (script_data->create_func.create_func) {
- script_data->create_func.create_func(
- (godot_object *)p_this,
- script_data->create_func.method_data);
- }
-
- _update_placeholder(sins);
-
- return sins;
- }
-#endif
-
NativeScriptInstance *nsi = memnew(NativeScriptInstance);
nsi->owner = p_this;
@@ -246,6 +229,19 @@ ScriptInstance *NativeScript::instance_create(Object *p_this) {
return nsi;
}
+PlaceHolderScriptInstance *NativeScript::placeholder_instance_create(Object *p_this) {
+#ifdef TOOLS_ENABLED
+ PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(NSL, Ref<Script>(this), p_this));
+ placeholders.insert(sins);
+
+ _update_placeholder(sins);
+
+ return sins;
+#else
+ return NULL;
+#endif
+}
+
bool NativeScript::instance_has(const Object *p_this) const {
return instance_owners.has((Object *)p_this);
}
@@ -1691,7 +1687,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;
}
diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h
index 8dd5ba3b9c..a6865c6243 100644
--- a/modules/gdnative/nativescript/nativescript.h
+++ b/modules/gdnative/nativescript/nativescript.h
@@ -149,6 +149,7 @@ public:
virtual StringName get_instance_base_type() const; // this may not work in all scripts, will return empty if so
virtual ScriptInstance *instance_create(Object *p_this);
+ virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this);
virtual bool instance_has(const Object *p_this) const;
virtual bool has_source_code() const;