From 49d5ed6bdef748992da6071f3a8ca8e730ef99e6 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 21 Apr 2011 20:55:01 +0100 Subject: [PATCH] Hopefully, final fix for #1786: We now make sure that a state file exists when trying to restore an order from it. The best effort to restore the previous order is made, though, in some cases, since we're matching against names which are translatable, a match might not be found, in that case, continue the effort though skip the non matching column name. On next load, everything should be fine since the state file will include the, now in use, translation. --- deluge/ui/gtkui/listview.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/deluge/ui/gtkui/listview.py b/deluge/ui/gtkui/listview.py index b96ca1ad2..35c7b7655 100644 --- a/deluge/ui/gtkui/listview.py +++ b/deluge/ui/gtkui/listview.py @@ -609,6 +609,9 @@ class ListView: return not model[iter][TORRENT_NAME_COL].lower().startswith(key.lower()) def restore_columns_order_from_state(self): + if self.state is None: + # No state file exists, so, no reordering can be done + return columns = self.treeview.get_columns() def find_column(header): for column in columns: @@ -629,6 +632,14 @@ class ListView: # It's in the right position continue column = find_column(col_state.name) + if not column: + log.debug("Could not find column matching \"%s\" on state." % + col_state.name) + # The cases where I've found that the column could not be found + # is when not using the english locale, ie, the default one, or + # when changing locales between runs. + # On the next load, all should be fine + continue self.treeview.move_column_after(column, column_at_position) # Get columns again to keep reordering since positions have changed columns = self.treeview.get_columns()