Skip to content

Commit 9406926

Browse files
committed
Fix deadlock possibility in threaded load of materials
1 parent 77dcf97 commit 9406926

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

scene/resources/canvas_item_material.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,13 @@ void CanvasItemMaterial::flush_changes() {
157157
}
158158

159159
void CanvasItemMaterial::_queue_shader_change() {
160+
if (!_is_initialized()) {
161+
return;
162+
}
163+
160164
MutexLock lock(material_mutex);
161165

162-
if (_is_initialized() && !element.in_list()) {
166+
if (!element.in_list()) {
163167
dirty_materials.add(&element);
164168
}
165169
}

scene/resources/material.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,9 +1878,13 @@ void BaseMaterial3D::flush_changes() {
18781878
}
18791879

18801880
void BaseMaterial3D::_queue_shader_change() {
1881+
if (!_is_initialized()) {
1882+
return;
1883+
}
1884+
18811885
MutexLock lock(material_mutex);
18821886

1883-
if (_is_initialized() && !element.in_list()) {
1887+
if (!element.in_list()) {
18841888
dirty_materials.add(&element);
18851889
}
18861890
}

scene/resources/particle_process_material.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,9 +1164,13 @@ void ParticleProcessMaterial::flush_changes() {
11641164
}
11651165

11661166
void ParticleProcessMaterial::_queue_shader_change() {
1167+
if (!_is_initialized()) {
1168+
return;
1169+
}
1170+
11671171
MutexLock lock(material_mutex);
11681172

1169-
if (_is_initialized() && !element.in_list()) {
1173+
if (!element.in_list()) {
11701174
dirty_materials.add(&element);
11711175
}
11721176
}

0 commit comments

Comments
 (0)