From ac3087eb4b07730e900ab6e9ea5a3ff180b59789 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 2 Jan 2020 17:19:14 +0100 Subject: Don't connect ShaderMaterial's `changed` signal when not in the editor This closes #34741. --- scene/resources/material.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'scene') 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 &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 &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); -- cgit v1.2.3