summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-01-03 14:42:10 +0100
committerGitHub <noreply@github.com>2020-01-03 14:42:10 +0100
commit147268a4272468af352782a95166d64d8b54c501 (patch)
tree063cb812681e9d0c501f13d0101b5d923f44d0e3 /scene/resources
parent0783874ff20cd868cb926ea1c283e6309ee6f077 (diff)
parentac3087eb4b07730e900ab6e9ea5a3ff180b59789 (diff)
Merge pull request #34755 from Calinou/shadermaterial-connect-editor-only
Don't connect ShaderMaterial's `changed` signal when not in the editor
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/material.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index b74b0fac1f..ab4dbb758a 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -30,6 +30,8 @@
#include "material.h"
+#include "core/engine.h"
+
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
#endif
@@ -191,7 +193,10 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) {
void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
- if (shader.is_valid()) {
+ // Only connect/disconnect the signal when running in the editor.
+ // This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
+ // does nothing in non-editor builds anyway. See GH-34741 for details.
+ if (shader.is_valid() && Engine::get_singleton()->is_editor_hint()) {
shader->disconnect("changed", this, "_shader_changed");
}
@@ -200,7 +205,10 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
RID rid;
if (shader.is_valid()) {
rid = shader->get_rid();
- shader->connect("changed", this, "_shader_changed");
+
+ if (Engine::get_singleton()->is_editor_hint()) {
+ shader->connect("changed", this, "_shader_changed");
+ }
}
VS::get_singleton()->material_set_shader(_get_material(), rid);