From 86c5a8df759a5205d662f137db182f6cae857f75 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Fri, 1 Dec 2017 23:08:25 +0800 Subject: [PATCH] Partial revert eac8838dc241f22f2aab9508633fdb2921373b7c. Fixes #7952. mapFromSource() didn't work as expected, when used in lessThan(), it sometimes returns an invalid QModelIndex. A crash is observed when filtering source model via filterAcceptsRow() in #7952, the crash is due to endless recursive of filterAcceptsRow() & lessThan() calling each other and mapFromSource() is the culprit of it. --- src/gui/categoryfilterproxymodel.cpp | 2 +- src/gui/properties/peerlistsortmodel.h | 4 ++-- src/gui/search/searchsortmodel.cpp | 4 ++-- src/gui/tagfilterproxymodel.cpp | 2 +- src/gui/transferlistsortmodel.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/categoryfilterproxymodel.cpp b/src/gui/categoryfilterproxymodel.cpp index f7066d97e..9c7a724b7 100644 --- a/src/gui/categoryfilterproxymodel.cpp +++ b/src/gui/categoryfilterproxymodel.cpp @@ -57,5 +57,5 @@ bool CategoryFilterProxyModel::lessThan(const QModelIndex &left, const QModelInd if (result != 0) return (result < 0); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); } diff --git a/src/gui/properties/peerlistsortmodel.h b/src/gui/properties/peerlistsortmodel.h index c1a78c224..451749b2c 100644 --- a/src/gui/properties/peerlistsortmodel.h +++ b/src/gui/properties/peerlistsortmodel.h @@ -56,14 +56,14 @@ protected: if (result != 0) return (result < 0); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); } break; default: if (left.data() != right.data()) return QSortFilterProxyModel::lessThan(left, right); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); }; } }; diff --git a/src/gui/search/searchsortmodel.cpp b/src/gui/search/searchsortmodel.cpp index 7a531ee7b..8e5a54cd4 100644 --- a/src/gui/search/searchsortmodel.cpp +++ b/src/gui/search/searchsortmodel.cpp @@ -116,14 +116,14 @@ bool SearchSortModel::lessThan(const QModelIndex &left, const QModelIndex &right if (result != 0) return (result < 0); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); } break; default: if (left.data() != right.data()) return base::lessThan(left, right); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); }; } diff --git a/src/gui/tagfilterproxymodel.cpp b/src/gui/tagfilterproxymodel.cpp index ffe572e8e..c80d9cfbb 100644 --- a/src/gui/tagfilterproxymodel.cpp +++ b/src/gui/tagfilterproxymodel.cpp @@ -57,5 +57,5 @@ bool TagFilterProxyModel::lessThan(const QModelIndex &left, const QModelIndex &r if (result != 0) return (result < 0); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); } diff --git a/src/gui/transferlistsortmodel.cpp b/src/gui/transferlistsortmodel.cpp index 97d80afd5..513db5b9d 100644 --- a/src/gui/transferlistsortmodel.cpp +++ b/src/gui/transferlistsortmodel.cpp @@ -98,7 +98,7 @@ bool TransferListSortModel::lessThan(const QModelIndex &left, const QModelIndex if (result != 0) return (result < 0); - return (mapFromSource(left) < mapFromSource(right)); + return (left < right); } case TorrentModel::TR_ADD_DATE: