From 74a3a06fa9d02bb2855e2cf4fe33900852e8fd82 Mon Sep 17 00:00:00 2001 From: Logan Higinbotham Date: Mon, 24 Oct 2022 19:54:56 -0400 Subject: [PATCH] Fix selection highlight issue for unordered layer lists set by script - fixes #3451 where layer selection highlighting was bugging out if the newly set selection was not ordered by layer ID - this seems to be an event interplay issue with the following sequence: - script sets the layer selection to some array - first step in handling that is to set the currently selected layers to be the full array, triggering LayerView::selectedLayersChanged to select the whole range - second step is to make sure that the mCurrentLayer variable is pointing to an object within that array selection, which in this bad case it is not, so we end up calling setSelectedLayers with one item, triggering LayerView::selectedLayersChanged again with a single item and effectively clearing out the selection we had just highlighted - fix this by doing the second step before the first step --- src/tiled/mapdocument.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tiled/mapdocument.cpp b/src/tiled/mapdocument.cpp index b29470e7e9..9ae4950fdd 100644 --- a/src/tiled/mapdocument.cpp +++ b/src/tiled/mapdocument.cpp @@ -281,11 +281,11 @@ void MapDocument::switchCurrentLayer(Layer *layer) void MapDocument::switchSelectedLayers(const QList &layers) { - setSelectedLayers(layers); - // Automatically make sure the current layer is one of the selected ones if (!layers.contains(mCurrentLayer)) setCurrentLayer(layers.isEmpty() ? nullptr : layers.first()); + + setSelectedLayers(layers); } /**