]> granicus.if.org Git - transmission/commitdiff
Fix sorting by progress (Qt client)
authorChristian Muehlhaeuser <muesli@gmail.com>
Thu, 30 Mar 2017 02:22:01 +0000 (04:22 +0200)
committerMike Gelfand <mikedld@mikedld.com>
Mon, 1 May 2017 09:44:47 +0000 (12:44 +0300)
Magnet transfers caused the by-progress sorting to become non-stable, as their
percentComplete() could return NaN. This patch fixes this by preferring active
downloads over magnet transfers, then sorting them by percentComplete().

qt/TorrentFilter.cc

index 07e4ca1168f8744fe80a3c6744d24527162c6d29..6fa78541f05319a72aa03a617fb5a83f694b3e03 100644 (file)
@@ -155,6 +155,11 @@ bool TorrentFilter::lessThan(QModelIndex const& left, QModelIndex const& right)
     // fall through
 
     case SortMode::SORT_BY_PROGRESS:
+        if (a->isMagnet() != b->isMagnet())
+        {
+            val = -compare(a->isMagnet(), b->isMagnet());
+        }
+
         if (val == 0)
         {
             val = compare(a->percentComplete(), b->percentComplete());