diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-01-01 23:06:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-01 23:06:35 +0100 |
commit | 2900b40507473d4d87e9373aab7f7dd61af0f6a2 (patch) | |
tree | 0a0d7ea3f97753b3834236448fa38f11a7719699 /scene/2d/tile_map.cpp | |
parent | 1ee69f29e5ce3fe1d207356320cb9e3990e1c536 (diff) | |
parent | 29b288238108ca34b25a58a9376f418d61e55420 (diff) | |
download | redot-engine-2900b40507473d4d87e9373aab7f7dd61af0f6a2.tar.gz |
Merge pull request #44839 from qarmin/fix_crash_tile_map
Do not iterate over map when removing its values
Diffstat (limited to 'scene/2d/tile_map.cpp')
-rw-r--r-- | scene/2d/tile_map.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 2e8216a875..01b7a9c260 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -1024,7 +1024,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<PosKey, Cell>::Element *E = tile_map.front(); E; E = E->next()) { + + Map<PosKey, Cell> temp_tile_map = tile_map; + for (Map<PosKey, Cell>::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); } |