diff --git a/scene/resources/canvas_item_material.cpp b/scene/resources/canvas_item_material.cpp index 6f43106ea98..91ce9704dd5 100644 --- a/scene/resources/canvas_item_material.cpp +++ b/scene/resources/canvas_item_material.cpp @@ -157,9 +157,13 @@ void CanvasItemMaterial::flush_changes() { } void CanvasItemMaterial::_queue_shader_change() { + if (!_is_initialized()) { + return; + } + MutexLock lock(material_mutex); - if (_is_initialized() && !element.in_list()) { + if (!element.in_list()) { dirty_materials.add(&element); } } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 5cdb7602d47..aa4b1aef322 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1970,9 +1970,13 @@ void BaseMaterial3D::flush_changes() { } void BaseMaterial3D::_queue_shader_change() { + if (!_is_initialized()) { + return; + } + MutexLock lock(material_mutex); - if (_is_initialized() && !element.in_list()) { + if (!element.in_list()) { dirty_materials.add(&element); } } diff --git a/scene/resources/particle_process_material.cpp b/scene/resources/particle_process_material.cpp index 09bc1fa8e42..ac1242138c0 100644 --- a/scene/resources/particle_process_material.cpp +++ b/scene/resources/particle_process_material.cpp @@ -1172,9 +1172,13 @@ void ParticleProcessMaterial::flush_changes() { } void ParticleProcessMaterial::_queue_shader_change() { + if (!_is_initialized()) { + return; + } + MutexLock lock(material_mutex); - if (_is_initialized() && !element.in_list()) { + if (!element.in_list()) { dirty_materials.add(&element); } }