Commit 9dc488c2 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

pk: make sure search queries eventually finish

BUG: 432384
parent b9ec2833
...@@ -453,6 +453,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -453,6 +453,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
if (!resources.isEmpty()) { if (!resources.isEmpty()) {
stream->setResources(resources); stream->setResources(resources);
} }
stream->finish();
}; };
runWhenInitialized(f, stream); runWhenInitialized(f, stream);
return stream; return stream;
...@@ -466,6 +467,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -466,6 +467,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
auto installedAndNameFilter = [filter] (AbstractResource *res) { auto installedAndNameFilter = [filter] (AbstractResource *res) {
return res->state() >= AbstractResource::Installed && (res->name().contains(filter.search) || res->packageName() == filter.search); return res->state() >= AbstractResource::Installed && (res->name().contains(filter.search) || res->packageName() == filter.search);
}; };
bool furtherSearch = false;
if (!toResolve.isEmpty()) { if (!toResolve.isEmpty()) {
resolvePackages(kTransform<QStringList>(toResolve, [] (AbstractResource* res) { return res->packageName(); })); resolvePackages(kTransform<QStringList>(toResolve, [] (AbstractResource* res) { return res->packageName(); }));
connect(m_resolveTransaction, &PKResolveTransaction::allFinished, this, [stream, toResolve, installedAndNameFilter] { connect(m_resolveTransaction, &PKResolveTransaction::allFinished, this, [stream, toResolve, installedAndNameFilter] {
...@@ -474,6 +476,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -474,6 +476,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
Q_EMIT stream->resourcesFound(resolved); Q_EMIT stream->resourcesFound(resolved);
stream->finish(); stream->finish();
}); });
furtherSearch = true;
} }
const auto resolved = kFilter<QVector<AbstractResource*>>(m_packages.packages, installedAndNameFilter); const auto resolved = kFilter<QVector<AbstractResource*>>(m_packages.packages, installedAndNameFilter);
...@@ -484,8 +487,12 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -484,8 +487,12 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
if (toResolve.isEmpty()) if (toResolve.isEmpty())
stream->finish(); stream->finish();
}); });
furtherSearch = true;
} }
if (!furtherSearch)
stream->finish();
}; };
runWhenInitialized(f, stream); runWhenInitialized(f, stream);
return stream; return stream;
...@@ -496,6 +503,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters ...@@ -496,6 +503,7 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
if (!resources.isEmpty()) { if (!resources.isEmpty()) {
stream->setResources(resources); stream->setResources(resources);
} }
stream->finish();
}; };
runWhenInitialized(f, stream); runWhenInitialized(f, stream);
return stream; return stream;
......
Supports Markdown
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