Commit 64c8778d authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

Make the PackageKit backend more resistant to crashes in PackageKit

Only report searches' results if they're successful

BUG: 376538
parent bffd42fb
......@@ -412,12 +412,14 @@ ResultsStream* PackageKitBackend::search(const AbstractResourcesBackend::Filters
connect(tArch, &PackageKit::Transaction::package, this, [tArch](PackageKit::Transaction::Info /*info*/, const QString &packageId){
tArch->setProperty("packageId", packageId);
});
connect(tArch, &PackageKit::Transaction::finished, stream, [stream, tArch, ids, this]() {
connect(tArch, &PackageKit::Transaction::finished, stream, [stream, tArch, ids, this](PackageKit::Transaction::Exit status) {
getPackagesFinished();
const auto packageId = tArch->property("packageId");
if (!packageId.isNull()) {
const auto res = resourcesByPackageNames<QVector<AbstractResource*>>({PackageKit::Daemon::packageName(packageId.toString())});
stream->resourcesFound(kFilter<QVector<AbstractResource*>>(res, [ids](AbstractResource* res){ return !ids.contains(res->appstreamId()); }));
if (status == PackageKit::Transaction::Exit::ExitSuccess) {
const auto packageId = tArch->property("packageId");
if (!packageId.isNull()) {
const auto res = resourcesByPackageNames<QVector<AbstractResource*>>({PackageKit::Daemon::packageName(packageId.toString())});
stream->resourcesFound(kFilter<QVector<AbstractResource*>>(res, [ids](AbstractResource* res){ return !ids.contains(res->appstreamId()); }));
}
}
stream->finish();
}, Qt::QueuedConnection);
......
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