diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -136,7 +136,7 @@ cmd = QStandardPaths::findExecutable(command(), { QStringLiteral("/sbin/"), QStringLiteral("/usr/sbin/"), QStringLiteral("/usr/local/sbin/") }); if (!QDBusConnection::systemBus().isConnected()) { - qWarning() << "Could not connect to DBus system bus"; + qWarning() << QDBusConnection::systemBus().lastError().message(); return false; } @@ -189,7 +189,7 @@ const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy if (!QDBusConnection::systemBus().isConnected()) { - qWarning() << "Could not connect to DBus system bus"; + qWarning() << QDBusConnection::systemBus().lastError().message(); return false; } @@ -250,7 +250,7 @@ bool rval = true; if (!QDBusConnection::systemBus().isConnected()) { - qWarning() << "Could not connect to DBus system bus"; + qWarning() << QDBusConnection::systemBus().lastError().message(); return false; } @@ -377,9 +377,10 @@ bool ExternalCommand::startHelper() { if (!QDBusConnection::systemBus().isConnected()) { - qWarning() << "Could not connect to DBus system bus"; + qWarning() << QDBusConnection::systemBus().lastError().message(); return false; } + QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus()); if (iface.isValid()) { exit(0); @@ -470,11 +471,8 @@ void DBusThread::run() { - if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface"))) { - qWarning() << QDBusConnection::systemBus().lastError().message(); - return; - } - if (!QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { + if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.applicationinterface")) || + !QDBusConnection::systemBus().registerObject(QStringLiteral("/Application"), this, QDBusConnection::ExportAllSlots)) { qWarning() << QDBusConnection::systemBus().lastError().message(); return; } diff --git a/src/util/externalcommandhelper.cpp b/src/util/externalcommandhelper.cpp --- a/src/util/externalcommandhelper.cpp +++ b/src/util/externalcommandhelper.cpp @@ -45,18 +45,9 @@ ActionReply ExternalCommandHelper::init(const QVariantMap& args) { ActionReply reply; - if (!QDBusConnection::systemBus().isConnected()) { - qWarning() << "Could not connect to DBus system bus"; - reply.addData(QStringLiteral("success"), false); - return reply; - } - if (!QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.helperinterface"))) { - qWarning() << QDBusConnection::systemBus().lastError().message(); - reply.addData(QStringLiteral("success"), false); - return reply; - } - if (!QDBusConnection::systemBus().registerObject(QStringLiteral("/Helper"), this, QDBusConnection::ExportAllSlots)) { + if (!QDBusConnection::systemBus().isConnected() || !QDBusConnection::systemBus().registerService(QStringLiteral("org.kde.kpmcore.helperinterface")) || + !QDBusConnection::systemBus().registerObject(QStringLiteral("/Helper"), this, QDBusConnection::ExportAllSlots)) { qWarning() << QDBusConnection::systemBus().lastError().message(); reply.addData(QStringLiteral("success"), false); return reply;