summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2017-04-12 22:43:45 (GMT)
committerAleix Pol <aleixpol@kde.org>2017-04-12 22:43:45 (GMT)
commitf122409447ebc8ce9cfd348db81236df1d640a56 (patch)
tree46d8b2b98bf1854f0246902af16815c22db27fe6
parent53702ce2d964843e78c18720a7d97b559bfa8a9c (diff)
Make sure categories are populated
-rw-r--r--libdiscover/backends/KNSBackend/KNSBackend.cpp2
-rw-r--r--libdiscover/backends/KNSBackend/tests/KNSBackendTest.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/libdiscover/backends/KNSBackend/KNSBackend.cpp b/libdiscover/backends/KNSBackend/KNSBackend.cpp
index 332666c..0565b8e 100644
--- a/libdiscover/backends/KNSBackend/KNSBackend.cpp
+++ b/libdiscover/backends/KNSBackend/KNSBackend.cpp
@@ -296,7 +296,7 @@ ResultsStream* KNSBackend::search(const AbstractResourcesBackend::Filters& filte
ret += r;
}
return new ResultsStream(QStringLiteral("KNS-installed"), ret);
- } else if (filter.category && filter.category->matchesCategoryName(m_categories.first())) {
+ } else if (filter.category && filter.category->matchesCategoryName(m_categories.constFirst())) {
return searchStream(filter.search);
} else if (!filter.search.isEmpty()) {
return searchStream(filter.search);
diff --git a/libdiscover/backends/KNSBackend/tests/KNSBackendTest.cpp b/libdiscover/backends/KNSBackend/tests/KNSBackendTest.cpp
index 84b7e0f..0de6cc4 100644
--- a/libdiscover/backends/KNSBackend/tests/KNSBackendTest.cpp
+++ b/libdiscover/backends/KNSBackend/tests/KNSBackendTest.cpp
@@ -73,7 +73,9 @@ QVector<AbstractResource*> KNSBackendTest::getResources(ResultsStream* stream)
QVector<AbstractResource*> KNSBackendTest::getAllResources(AbstractResourcesBackend* backend)
{
AbstractResourcesBackend::Filters f;
- f.category = CategoryModel::global()->rootCategories().first();
+ if (CategoryModel::global()->rootCategories().isEmpty())
+ CategoryModel::global()->populateCategories();
+ f.category = CategoryModel::global()->rootCategories().constFirst();
return getResources(backend->search(f));
}