From 927010e90fcd9134a18bd91de9821fd469f82eaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Thu, 31 Dec 2020 15:47:37 +0100 Subject: [PATCH] Do not iterate over map when removing its values (cherry picked from commit 29b288238108ca34b25a58a9376f418d61e55420) --- scene/2d/tile_map.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index e3d425406cb..24161f915d7 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1049,8 +1049,9 @@ void TileMap::update_dirty_bitmask() { void TileMap::fix_invalid_tiles() { ERR_FAIL_COND_MSG(tile_set.is_null(), "Cannot fix invalid tiles if Tileset is not open."); - for (Map::Element *E = tile_map.front(); E; E = E->next()) { + Map temp_tile_map = tile_map; + for (Map::Element *E = temp_tile_map.front(); E; E = E->next()) { if (!tile_set->has_tile(get_cell(E->key().x, E->key().y))) { set_cell(E->key().x, E->key().y, INVALID_CELL); }