5b53c8b
From 396417bcd045c387fd5ee6cae6a18106324a06a4 Mon Sep 17 00:00:00 2001
5b53c8b
From: Calum Lind <calumlind+deluge@gmail.com>
5b53c8b
Date: Sun, 29 Oct 2017 11:12:56 +0000
5b53c8b
Subject: [#3124|GTKUI] Fix comparing Name str if value is None
5b53c8b
5b53c8b
The original fix was not correct as the strcoll function cannot
5b53c8b
accept None only strings. This fix ensures that the value is an
5b53c8b
empty string if None for comparison.
5b53c8b
---
5b53c8b
 deluge/ui/gtkui/gtkui.py       |  4 ++--
5b53c8b
 deluge/ui/gtkui/torrentview.py | 19 +++++++++----------
5b53c8b
 2 files changed, 11 insertions(+), 12 deletions(-)
5b53c8b
5b53c8b
diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py
5b53c8b
index eecd026..14954b1 100644
5b53c8b
--- a/deluge/ui/gtkui/gtkui.py
5b53c8b
+++ b/deluge/ui/gtkui/gtkui.py
5b53c8b
@@ -294,8 +294,8 @@ class GtkUI(object):
5b53c8b
         try:
5b53c8b
             reactor.run()
5b53c8b
         except OverflowError:
5b53c8b
-            # Ticket 3010 reports an error that cannot replicate so catch
5b53c8b
-            # it and ignore it to prevent spamming logs.
5b53c8b
+            # Ticket #3010 reports an overflow error from twisted glibbase that
5b53c8b
+            # cannot be replicated so catch it and ignore it to prevent spamming logs.
5b53c8b
             pass
5b53c8b
         self.shutdown()
5b53c8b
         gtk.gdk.threads_leave()
5b53c8b
diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py
5b53c8b
index 6befddb..b210153 100644
5b53c8b
--- a/deluge/ui/gtkui/torrentview.py
5b53c8b
+++ b/deluge/ui/gtkui/torrentview.py
5b53c8b
@@ -171,18 +171,17 @@ def cell_data_queue(column, cell, model, row, data):
5b53c8b
         cell.set_property("text", str(value + 1))
5b53c8b
 
5b53c8b
 def str_nocase_sort(model, iter1, iter2, data):
5b53c8b
-    """
5b53c8b
-    Sort string column data with locale.strcoll which (allegedly)
5b53c8b
-    uses ISO 14651.
5b53c8b
+    """Sort string column data using ISO 14651 in lowercase.
5b53c8b
+
5b53c8b
+    Uses locale.strcoll which (allegedly) uses ISO 14651. Compares first
5b53c8b
+    value with second and returns -1, 0, 1 for where it should be placed.
5b53c8b
 
5b53c8b
     """
5b53c8b
-    try:
5b53c8b
-        v1 = model[iter1][data].lower()
5b53c8b
-        v2 = model[iter2][data].lower()
5b53c8b
-    except AttributeError:
5b53c8b
-        # Catch None type for value.
5b53c8b
-        v1 = model[iter1][data]
5b53c8b
-        v2 = model[iter2][data]
5b53c8b
+    v1 = model[iter1][data]
5b53c8b
+    v2 = model[iter2][data]
5b53c8b
+    # Catch any values of None from model.
5b53c8b
+    v1 = v1.lower() if v1 else ""
5b53c8b
+    v2 = v2.lower() if v2 else ""
5b53c8b
     return strcoll(v1, v2)
5b53c8b
 
5b53c8b
 def queue_peer_seed_sort_function(v1, v2):
5b53c8b
-- 
5b53c8b
cgit v1.1
5b53c8b