Commit 426b3dce authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

packagekit: Show a passive message when an executable fails to run

Whatever the reason might be. This should never happen as we've already
asserted that the desktop file exists so it's mostly to indicate where
the bug is as it was the case in the bug we're closing.

BUG: 432683
parent 6d1c5ff5
......@@ -17,7 +17,6 @@
#include <QProcess>
#include <QStandardPaths>
#include <QDebug>
#include "config-paths.h"
#include "utils.h"
AppPackageKitResource::AppPackageKitResource(const AppStream::Component& data, const QString &packageName, PackageKitBackend* parent)
......@@ -210,7 +209,7 @@ void AppPackageKitResource::invokeApplication() const
const auto allServices = QStandardPaths::locateAll(QStandardPaths::ApplicationsLocation, m_appdata.id());
if (!allServices.isEmpty()) {
const auto packageServices = kFilter<QStringList>(allServices, [filenames](const QString &file) { return filenames.contains(file); });
QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), {packageServices});
runService(packageServices);
return;
} else {
const QStringList exes = m_appdata.provided(AppStream::Provided::KindBinary).items();
......@@ -228,7 +227,7 @@ void AppPackageKitResource::invokeApplication() const
return false;
});
if (!desktopFiles.isEmpty()) {
QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), { desktopFiles });
runService(desktopFiles);
return;
}
}
......
......@@ -11,7 +11,6 @@
#include <PackageKit/Daemon>
#include <PackageKit/Details>
#include <utils.h>
#include "config-paths.h"
#include "libdiscover_backend_debug.h"
LocalFilePKResource::LocalFilePKResource(QUrl path, PackageKitBackend* parent)
......@@ -84,5 +83,5 @@ void LocalFilePKResource::setDetails(const PackageKit::Details& details)
void LocalFilePKResource::invokeApplication() const
{
QProcess::startDetached(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), {m_exec});
runService({m_exec});
}
......@@ -9,10 +9,13 @@
#include "PackageKitBackend.h"
#include "PackageKitMessages.h"
#include <KLocalizedString>
#include <KShell>
#include <PackageKit/Daemon>
#include <QJsonArray>
#include <QProcess>
#include <QDebug>
#include <utils.h>
#include "config-paths.h"
#if defined(WITH_MARKDOWN)
extern "C" {
......@@ -351,3 +354,17 @@ bool PackageKitResource::extendsItself() const
}
return true;
}
void PackageKitResource::runService(const QStringList& desktopFilePaths) const
{
for (const QString &desktopFilePath : desktopFilePaths) {
auto p = new QProcess(parent());
connect(p, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), this, [this, p] (int exitCode, QProcess::ExitStatus exitStatus) {
if (exitCode != 0) {
backend()->passiveMessage(i18n("Failed to start '%1'", KShell::joinArgs(p->arguments())));
}
p->deleteLater();
});
p->start(QStringLiteral(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "/discover/runservice"), {desktopFilePath});
}
}
......@@ -64,6 +64,8 @@ class PackageKitResource : public AbstractResource
bool extendsItself() const;
void runService(const QStringList &desktopFilePaths) const;
Q_SIGNALS:
void dependenciesFound(const QJsonObject& dependencies);
......
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