Fix TileMapLayer bug where dirty cells could be marked twice #102688
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds additional checks to
TileMapLayer::_build_runtime_update_tile_data_for_cell
to ensure that dirty cells have not already been added to the dirty cells list before callingdirty.cell_list.add(...)
. Previously, updating a cell and callingnotify_runtime_tile_data_update
in the same frame or through coroutines could cause ordering issues here resulting in a large number of error messages being printed.Using the MRC provided in the linked issue, I verified that the errors are no longer being printed, and calling
notify_runtime_tile_data_update
usingcall_deferred
is no longer necessaryI'm also attaching an MRC to this PR for the case where messages can still be printed when using
call_deferred
if coroutines are involved. Adding these additional checks prevent the error messages in this MRC as well: Coroutine MRC