From 9cbe7cf0ff10cb51ff69e8494088667e23d6f703 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Sun, 5 Jan 2025 18:24:09 -0500 Subject: [PATCH] Backport PR #23417: PR: Recreate thumbnails list after dropping one in a new position (Plots) --- 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(