OSDN Git Service

Make sort exception safer.
authorAiwota Programmer <aiwotaprog@tetteke.tk>
Mon, 18 Sep 2006 10:59:57 +0000 (19:59 +0900)
committerAiwota Programmer <aiwotaprog@tetteke.tk>
Mon, 18 Sep 2006 10:59:57 +0000 (19:59 +0900)
src/FukuiNoNamari/threadlistmodel.py

index 34484b6..1b7cef6 100644 (file)
@@ -107,27 +107,30 @@ class ThreadListModel(gtk.GenericTreeModel):
         return self.sort_column_name, self.sort_reverse
 
     def do_sort(self, column_name, reverse):
+        sort_list = self.list[:]
         if self.column_types[self.column_names.index(column_name)] == str:
-            self.list.sort(None, lambda dic: dic[column_name], reverse)
+            sort_list.sort(None, lambda dic: dic[column_name], reverse)
         else:
             h = lambda x, y: self.compare(x, y, reverse)
-            self.list.sort(h, lambda dic: dic[column_name], reverse)
+            sort_list.sort(h, lambda dic: dic[column_name], reverse)
+        self.list = sort_list
         self.build_order_dict()
 
     def sort(self, column_name, order_specified=False, reverse=False):
         old_order_dict = self.order_dict
 
         if order_specified:
-            self.sort_reverse = reverse
+            sort_reverse = reverse
         else:
             if column_name == self.sort_column_name:
                 # sort reverse
-                self.sort_reverse = not self.sort_reverse
+                sort_reverse = not self.sort_reverse
             else:
-                self.sort_reverse = False
-        self.sort_column_name = column_name
+                sort_reverse = False
 
-        self.do_sort(self.sort_column_name, self.sort_reverse)
+        self.do_sort(column_name, sort_reverse)
+        self.sort_column_name = column_name
+        self.sort_reverse = sort_reverse
 
         neworder = [old_order_dict[item["id"]] for item in self.list]
         self.rows_reordered(None, None, neworder)