From e066d45eb694a42b1bec1d9670c398051af3384b Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 2 Jun 2021 18:54:24 -0300 Subject: [PATCH] Fix keeping tiles (that are removed) references into clipboard Without this fix we can reproduce an ASSERT() fail in Object::setId() from AddTile::onRedo() (or RemoveTile::onUndo()) doing the following steps: 1. Creating a tilemap layer with some tiles 2. Selecting a set of tiles (in tile mode) and using "Edit > Cut" (this was creating a copy of the tileset with the original images) 3. Resizing tileset to 0 (to remove all tiles) 4. And then undoing (to restore all removed tiles) The ASSERT() was because the restored tiles wanted to use the same ID of the tile images in the clipboard. --- src/app/util/clipboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp index c1db89cf0..582cfa8d2 100644 --- a/src/app/util/clipboard.cpp +++ b/src/app/util/clipboard.cpp @@ -269,7 +269,7 @@ bool Clipboard::copyFromDocument(const Site& site, bool merged) image, (mask ? new Mask(*mask): nullptr), (pal ? new Palette(*pal): nullptr), - new Tileset(*ts), + Tileset::MakeCopyCopyingImages(ts), true, // set native clipboard site.layer() && !site.layer()->isBackground());