summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-09-21 13:52:57 +0200
committerGitHub <noreply@github.com>2021-09-21 13:52:57 +0200
commit91960b7b81523cb545b2dfb47c235cf21dd460f3 (patch)
tree6812efcb8a4736e89e2b8a84a22bf30cfff302d1
parent8085affdb109123f68059e37beb2236a1f94de1a (diff)
parentdbe757102c6503eb564c9edc699c89afe63b91cd (diff)
Merge pull request #52466 from tcoxon/fix_43733_4.0
Prevent shaders from generating code before the constructor finishes.
-rw-r--r--scene/resources/canvas_item_material.cpp3
-rw-r--r--scene/resources/canvas_item_material.h1
-rw-r--r--scene/resources/material.cpp3
-rw-r--r--scene/resources/material.h1
-rw-r--r--scene/resources/particles_material.cpp3
-rw-r--r--scene/resources/particles_material.h1
6 files changed, 9 insertions, 3 deletions
diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp
index 7501efea9e..fa95ab0e79 100644
--- a/scene/resources/canvas_item_material.cpp
+++ b/scene/resources/canvas_item_material.cpp
@@ -161,7 +161,7 @@ void CanvasItemMaterial::flush_changes() {
void CanvasItemMaterial::_queue_shader_change() {
MutexLock lock(material_mutex);
- if (!element.in_list()) {
+ if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}
}
@@ -287,6 +287,7 @@ CanvasItemMaterial::CanvasItemMaterial() :
set_particles_anim_loop(false);
current_key.invalid_key = 1;
+ is_initialized = true;
_queue_shader_change();
}
diff --git a/scene/resources/canvas_item_material.h b/scene/resources/canvas_item_material.h
index 0a813e0ae5..37cd4de136 100644
--- a/scene/resources/canvas_item_material.h
+++ b/scene/resources/canvas_item_material.h
@@ -102,6 +102,7 @@ private:
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
+ bool is_initialized = false;
BlendMode blend_mode = BLEND_MODE_MIX;
LightMode light_mode = LIGHT_MODE_NORMAL;
bool particles_animation = false;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 643b0e34b9..3a6af3afb0 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -1301,7 +1301,7 @@ void BaseMaterial3D::flush_changes() {
void BaseMaterial3D::_queue_shader_change() {
MutexLock lock(material_mutex);
- if (!element.in_list()) {
+ if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}
}
@@ -2777,6 +2777,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
flags[FLAG_USE_TEXTURE_REPEAT] = true;
+ is_initialized = true;
_queue_shader_change();
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index e2838e1399..5d7a5324ca 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -440,6 +440,7 @@ private:
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
+ bool is_initialized = false;
bool orm;
Color albedo;
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index 0495a9e92c..d9ec0bfd69 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -741,7 +741,7 @@ void ParticlesMaterial::flush_changes() {
void ParticlesMaterial::_queue_shader_change() {
MutexLock lock(material_mutex);
- if (!element.in_list()) {
+ if (is_initialized && !element.in_list()) {
dirty_materials->add(&element);
}
}
@@ -1533,6 +1533,7 @@ ParticlesMaterial::ParticlesMaterial() :
current_key.invalid_key = 1;
+ is_initialized = true;
_queue_shader_change();
}
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index 8ab26aff77..36bc456978 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -226,6 +226,7 @@ private:
_FORCE_INLINE_ void _queue_shader_change();
_FORCE_INLINE_ bool _is_shader_dirty() const;
+ bool is_initialized = false;
Vector3 direction;
float spread;
float flatness;