summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <[email protected]>2018-06-01 18:12:17 +0200
committerAleix Pol <[email protected]>2018-06-01 18:12:17 +0200
commit71cea8baad0b6f1a7433b04ecffc812c1eaf1422 (patch)
tree63ab1b4fd7b99d2bed093f6e7f4ddfce07412dfa
parentfcec1090e2f4237e9b8c3cfe175c95e77539cd68 (diff)
Make sure we always remove duplicates before inserting
Otherwise we may introduce such duplicates on some code paths. BUG: 393484
-rw-r--r--libdiscover/resources/ResourcesProxyModel.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/libdiscover/resources/ResourcesProxyModel.cpp b/libdiscover/resources/ResourcesProxyModel.cpp
index 2e22d6b..4a29617 100644
--- a/libdiscover/resources/ResourcesProxyModel.cpp
+++ b/libdiscover/resources/ResourcesProxyModel.cpp
@@ -175,9 +175,6 @@ void ResourcesProxyModel::addResources(const QVector<AbstractResource *>& _res)
if (res.isEmpty())
return;
- if (!m_filters.allBackends) {
- removeDuplicates(res);
- }
if (!m_sortByRelevancy)
qSort(res.begin(), res.end(), [this](AbstractResource* res, AbstractResource* res2){ return lessThan(res, res2); });
@@ -446,9 +443,17 @@ bool ResourcesProxyModel::isSorted(const QVector<AbstractResource*> & resources)
return true;
}
-void ResourcesProxyModel::sortedInsertion(const QVector<AbstractResource*> & resources)
+void ResourcesProxyModel::sortedInsertion(const QVector<AbstractResource*> & _res)
{
+ auto resources = _res;
Q_ASSERT(!resources.isEmpty());
+
+ if (!m_filters.allBackends) {
+ removeDuplicates(resources);
+ if (resources.isEmpty())
+ return;
+ }
+
if (m_sortByRelevancy || m_displayedResources.isEmpty()) {
// Q_ASSERT(m_sortByRelevancy || isSorted(resources));
int rows = rowCount();