From 394b8bb2aae4b5e3764d44dc9d46dae646e5cdc1 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 26 Oct 2020 18:45:21 -0300 Subject: [PATCH] Fix clearing/cutting several tiles at the same time from the tileset --- src/app/ui/color_bar.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index 967a2c86d..51d027633 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -1011,8 +1011,14 @@ app::Color ColorBar::onPaletteViewGetBackgroundIndex() return getBgColor(); } -void ColorBar::onTilesViewClearTiles(const doc::PalettePicks& picks) +void ColorBar::onTilesViewClearTiles(const doc::PalettePicks& _picks) { + // Copy the collection of selected tiles because in case that the + // user want to delete a range of tiles (several tiles at the same + // time), after the first cmd::RemoveTile() is executed this + // collection (_picks) will be modified and we'll lost the other + // selected tiles to remove. + doc::PalettePicks picks = _picks; try { ContextWriter writer(UIContext::instance(), 500); Sprite* sprite = writer.sprite(); @@ -1021,7 +1027,7 @@ void ColorBar::onTilesViewClearTiles(const doc::PalettePicks& picks) auto tileset = m_tilesView.tileset(); Tx tx(writer.context(), "Clear Tiles", ModifyDocument); - for (doc::tile_index ti=0; ti=0; --ti) { if (picks[ti]) tx(new cmd::RemoveTile(tileset, ti)); }