From de174eedef92fb7e9577fb40cca7044a254291c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Mon, 11 Sep 2017 21:43:08 +0200 Subject: [PATCH] Remove record from the Group in reversed order This limit the number of cursor changes on large list as the changes are that the cursor is still on the top. issue6741 review39661002 --- tryton/gui/window/view_form/model/group.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tryton/gui/window/view_form/model/group.py b/tryton/gui/window/view_form/model/group.py index 9ea63d266a..00937395e7 100644 --- a/tryton/gui/window/view_form/model/group.py +++ b/tryton/gui/window/view_form/model/group.py @@ -124,10 +124,12 @@ class Group(SignalEvent, list): del self.__id2record[record.id] def clear(self): - for record in self[:]: + # Use reversed order to minimize the cursor reposition as the cursor + # has more chances to be on top of the list. + for record in reversed(self[:]): self.signal('group-list-changed', ('record-removed', record)) record.destroy() - self.pop(0) + self.pop() self.__id2record = {} self.record_removed, self.record_deleted = [], []