Commit df12760c authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Cap the amount of KNS requests we do per query

There are a lot of wallpapers...

BUG: 389605
parent d3eddd3d
......@@ -213,7 +213,7 @@ void KNSBackend::receivedEntries(const KNSCore::EntryInternal::List& entries)
Q_EMIT receivedResources(resources);
}
if(resources.isEmpty()) {
if(resources.isEmpty() || m_stopSearching) {
Q_EMIT searchFinished();
Q_EMIT availableForQueries();
setFetching(false);
......@@ -346,6 +346,12 @@ ResultsStream* KNSBackend::searchStream(const QString &searchText)
m_onePage = false;
m_responsePending = true;
QSharedPointer<int> count(new int(0));
connect(this, &KNSBackend::receivedResources, stream, [this, count](const QVector<AbstractResource*>& resources){
*count += resources.count();
if (*count>2000)
m_stopSearching = true;
});
connect(this, &KNSBackend::receivedResources, stream, &ResultsStream::resourcesFound);
connect(this, &KNSBackend::searchFinished, stream, &ResultsStream::finish);
connect(this, &KNSBackend::startingSearch, stream, &ResultsStream::finish);
......
......@@ -83,6 +83,7 @@ private:
ResultsStream* searchStream(const QString &searchText);
bool m_onePage = false;
bool m_stopSearching = false;
bool m_responsePending = false;
bool m_fetching;
bool m_isValid;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment