From 341da0d3e7415ba174c0a931e90f49afacbd6af5 Mon Sep 17 00:00:00 2001 From: Manuel Date: Thu, 23 Nov 2023 11:50:36 +0100 Subject: [PATCH] Remove before update before add in DB editor To try and avoid ugly transient states. For example, if I remove and add stuff and the addition is processed first, some views might complain they don't find the items I removed. So it's better to process the removal first so the view is clean when the addition is processed. --- spinetoolbox/fetch_parent.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spinetoolbox/fetch_parent.py b/spinetoolbox/fetch_parent.py index 880be227d..ec7cecdcf 100644 --- a/spinetoolbox/fetch_parent.py +++ b/spinetoolbox/fetch_parent.py @@ -90,15 +90,15 @@ def increment_position(self, db_map): def _apply_pending_changes(self): if self.is_obsolete: return - for db_map in list(self._items_to_add): - data = self._items_to_add.pop(db_map) - self.handle_items_added({db_map: data}) - for db_map in list(self._items_to_update): - data = self._items_to_update.pop(db_map) - self.handle_items_updated({db_map: data}) for db_map in list(self._items_to_remove): data = self._items_to_remove.pop(db_map) self.handle_items_removed({db_map: data}) + for db_map in list(self._items_to_update): + data = self._items_to_update.pop(db_map) + self.handle_items_updated({db_map: data}) + for db_map in list(self._items_to_add): + data = self._items_to_add.pop(db_map) + self.handle_items_added({db_map: data}) QTimer.singleShot(0, lambda: self.set_busy(False)) def bind_item(self, item, db_map):