Skip to content

Commit 7404873

Browse files
committed
Fix TileMapLayer bug where dirty cells could be marked twice
When using runtime data in a TileMapLayer, calling notify_runtime_tile_update can cause error messages to be printed to the console if the same cell has been set or erased in the same frame. This could be partially worked around by using call_deferred on notify_runtime_tile_update, but the problem could re-emerge if those updates were being made in coroutines. This commit addresses the issue by adding an additional check to the dirty cell marking of the TileMapLayer when notify_runtime_tile_update is called. This check ensures that the cell has not already been added to the dirty cell list, preventing the condition that causes the error message.
1 parent 296de7d commit 7404873

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

scene/2d/tile_map_layer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ void TileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_cell_dat
14131413

14141414
tile_map_node->GDVIRTUAL_CALL(_tile_data_runtime_update, layer_index_in_tile_map_node, r_cell_data.coords, tile_data_runtime_use);
14151415

1416-
if (p_auto_add_to_dirty_list) {
1416+
if (p_auto_add_to_dirty_list && !r_cell_data.dirty_list_element.in_list()) {
14171417
dirty.cell_list.add(&r_cell_data.dirty_list_element);
14181418
}
14191419
}
@@ -1428,7 +1428,7 @@ void TileMapLayer::_build_runtime_update_tile_data_for_cell(CellData &r_cell_dat
14281428

14291429
GDVIRTUAL_CALL(_tile_data_runtime_update, r_cell_data.coords, tile_data_runtime_use);
14301430

1431-
if (p_auto_add_to_dirty_list) {
1431+
if (p_auto_add_to_dirty_list && !r_cell_data.dirty_list_element.in_list()) {
14321432
dirty.cell_list.add(&r_cell_data.dirty_list_element);
14331433
}
14341434
}

0 commit comments

Comments
 (0)