From: Christian Muehlhaeuser Date: Thu, 30 Mar 2017 02:22:01 +0000 (+0200) Subject: Fix sorting by progress (Qt client) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6dd034b8266c3e5a909108f8994eb25af8cfc5ec;p=transmission Fix sorting by progress (Qt client) 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(). --- diff --git a/qt/TorrentFilter.cc b/qt/TorrentFilter.cc index 07e4ca116..6fa78541f 100644 --- a/qt/TorrentFilter.cc +++ b/qt/TorrentFilter.cc @@ -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());