Fix copy_tiles_in_tileset() case when the "beforeIndex" is out of range

This commit is contained in:
David Capello 2020-07-16 19:00:31 -03:00
parent 6b43f7ca05
commit 7b7fa29710

View File

@ -757,6 +757,11 @@ void copy_tiles_in_tileset(
for (int i=0; i<m; ++i) {
picks[i] = (i >= beforeIndex && i < beforeIndex + npicks);
if (picks[i]) {
// Fill the gap between the end of the tileset and the
// "beforeIndex" with empty tiles
while (tileset->size() < i)
cmds->executeAndAdd(new cmd::AddTile(tileset, tileset->makeEmptyTile()));
tileset->insert(i, newTiles[j++]);
cmds->executeAndAdd(new cmd::AddTile(tileset, i));
}