Skip to content

Commit 681fce3

Browse files
Fixes labscript-suite#16, routines not reordering correctly with GUI buttons.
Problem was confusing a passive transformation with an active transformation: passive transformation: constructing a new list from a list of indices saying where in the old list each item should come from (what we were doing) active transformation: constructing a new list out of a list of indices for where in the new list items in the old list should be moved to (what we should have been doing) When a single routine was moved, this simply swapped it with the one above or below it and so a passive and active transformation of the order are identical. But for reordering multiple routines at once it gave the wrong result.
1 parent c025214 commit 681fce3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

__main__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -717,8 +717,11 @@ def reorder(self, order):
717717
name_item.setData(new_index, self.ROLE_SORTINDEX)
718718
self.ui.treeView.sortByColumn(self.COL_NAME, QtCore.Qt.AscendingOrder)
719719
# Apply new order to our list of routines too:
720-
self.routines = [self.routines[i] for i in order]
721-
720+
reordered_routines = [None]*len(order)
721+
for routine, index in zip(self.routines, order):
722+
reordered_routines[index] = routine
723+
self.routines = reordered_routines
724+
722725
def update_select_all_checkstate(self):
723726
with self.select_all_checkbox_state_changed_disconnected:
724727
all_states = []

0 commit comments

Comments
 (0)