summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2017-10-29 11:12:56 +0000
committerCalum Lind <calumlind+deluge@gmail.com>2017-10-29 11:16:21 +0000
commit396417bcd045c387fd5ee6cae6a18106324a06a4 (patch)
treeb574161524aaa856354ca04e3f4c2705da9cac32
parentb13da8a42a01d3d7e2a71bcae5d9aceecdcb6e82 (diff)
downloaddeluge-396417bcd045c387fd5ee6cae6a18106324a06a4.tar.gz
deluge-396417bcd045c387fd5ee6cae6a18106324a06a4.tar.bz2
deluge-396417bcd045c387fd5ee6cae6a18106324a06a4.zip
[#3124|GTKUI] Fix comparing Name str if value is None
The original fix was not correct as the strcoll function cannot accept None only strings. This fix ensures that the value is an empty string if None for comparison.
-rw-r--r--deluge/ui/gtkui/gtkui.py4
-rw-r--r--deluge/ui/gtkui/torrentview.py19
2 files changed, 11 insertions, 12 deletions
diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py
index eecd02613..14954b179 100644
--- a/deluge/ui/gtkui/gtkui.py
+++ b/deluge/ui/gtkui/gtkui.py
@@ -294,8 +294,8 @@ class GtkUI(object):
try:
reactor.run()
except OverflowError:
- # Ticket 3010 reports an error that cannot replicate so catch
- # it and ignore it to prevent spamming logs.
+ # Ticket #3010 reports an overflow error from twisted glibbase that
+ # cannot be replicated so catch it and ignore it to prevent spamming logs.
pass
self.shutdown()
gtk.gdk.threads_leave()
diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py
index 6befddba3..b21015316 100644
--- a/deluge/ui/gtkui/torrentview.py
+++ b/deluge/ui/gtkui/torrentview.py
@@ -171,18 +171,17 @@ def cell_data_queue(column, cell, model, row, data):
cell.set_property("text", str(value + 1))
def str_nocase_sort(model, iter1, iter2, data):
- """
- Sort string column data with locale.strcoll which (allegedly)
- uses ISO 14651.
+ """Sort string column data using ISO 14651 in lowercase.
+
+ Uses locale.strcoll which (allegedly) uses ISO 14651. Compares first
+ value with second and returns -1, 0, 1 for where it should be placed.
"""
- try:
- v1 = model[iter1][data].lower()
- v2 = model[iter2][data].lower()
- except AttributeError:
- # Catch None type for value.
- v1 = model[iter1][data]
- v2 = model[iter2][data]
+ v1 = model[iter1][data]
+ v2 = model[iter2][data]
+ # Catch any values of None from model.
+ v1 = v1.lower() if v1 else ""
+ v2 = v2.lower() if v2 else ""
return strcoll(v1, v2)
def queue_peer_seed_sort_function(v1, v2):