From c30ab5a01ca03d9eb47dcbabc92289f495d4f3de Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 5 Jan 2025 13:38:55 -0500 Subject: [PATCH] Plots: Recreate thumbnails list after dropping one in a new position --- spyder/plugins/plots/widgets/figurebrowser.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spyder/plugins/plots/widgets/figurebrowser.py b/spyder/plugins/plots/widgets/figurebrowser.py index 859a8591fc4..ece97f0b937 100644 --- a/spyder/plugins/plots/widgets/figurebrowser.py +++ b/spyder/plugins/plots/widgets/figurebrowser.py @@ -847,6 +847,12 @@ def dropEvent(self, event): self.scene.insertWidget(i - 1, dropped_thumbnail) break + # Recreate thumbnails list to take into account the new order + # Fixes spyder-ide/spyder#22458 + self._thumbnails = [] + for i in range(n_thumbnails): + self._thumbnails.append(self.scene.itemAt(i).widget()) + event.accept() # ---- Save Figure @@ -1041,7 +1047,7 @@ def remove_thumbnail(self, thumbnail): if thumbnail in self._thumbnails: self._thumbnails.remove(thumbnail) - # Select a new thumbnail if any : + # Select a new thumbnail, if any if thumbnail == self.current_thumbnail: if len(self._thumbnails) > 0: self.set_current_index(