Fix crash on debug when painting on removed tiles after resizing the tileset

This commit is contained in:
David Capello 2021-06-01 10:11:24 -03:00
parent 0b33d15462
commit 7bcd511315

View File

@ -783,7 +783,11 @@ static void remove_unused_tiles_from_tileset(
const doc::tile_index ti = doc::tile_geti(t);
n = std::max<int>(n, ti+1);
#ifdef _DEBUG
++tilesHistogram2[ti];
// This check is necessary in case the tilemap has a reference
// to a tile outside the valid range (e.g. when we resize the
// tileset deleting tiles that will not be present anymore)
if (ti >= 0 && ti < tilesHistogram2.size())
++tilesHistogram2[ti];
#endif
}
});