Fix crash deleting all tiles from tileset and remapping

This commit is contained in:
David Capello 2020-10-26 17:00:05 -03:00
parent 7f487c1294
commit 4db4e77c78

View File

@ -813,17 +813,20 @@ void ColorBar::onRemapTilesButtonClick()
doc::Tileset* tileset = m_tilesView.tileset(); doc::Tileset* tileset = m_tilesView.tileset();
std::vector<ImageRef> tilemaps; std::vector<ImageRef> tilemaps;
sprite->getTilemapsByTileset(tileset, tilemaps); sprite->getTilemapsByTileset(tileset, tilemaps);
PalettePicks usedTiles(tileset->size());
for (const ImageRef& tilemap : tilemaps) { const int n = std::max(m_oldTileset->size(),
for (const doc::tile_t t : LockImageBits<TilemapTraits>(tilemap.get())) tileset->size());
if (t != doc::tile_i_notile) PalettePicks usedTiles(n);
usedTiles[doc::tile_geti(t)] = true;
if (n > 0) {
for (const ImageRef& tilemap : tilemaps) {
for (const doc::tile_t t : LockImageBits<TilemapTraits>(tilemap.get()))
if (t != doc::tile_i_notile)
usedTiles[doc::tile_geti(t)] = true;
}
} }
// Remap all tiles in the same order as in newTileset // Remap all tiles in the same order as in newTileset
const int n = std::max(m_oldTileset->size(),
tileset->size());
Remap remap(n); Remap remap(n);
bool existMapToEmpty = false; bool existMapToEmpty = false;