Commit 0d15048e authored by Alex Richardson's avatar Alex Richardson Committed by Albert Astals Cid
Browse files

Avoid crashing on startup if DBus isn't running

I am trying to run Okular on a minimal FreeBSD CHERI-RISC-V QEMU
instance and I haven't got DBus running. Without this change, I get
crashes because QDBusConnection::sessionBus().interface() returns NULL
if DBus isn't running.
parent 21bc8bd0
Pipeline #72121 passed with stage
in 9 minutes and 36 seconds
......@@ -48,7 +48,12 @@ static bool attachExistingInstance(const QStringList &paths, const QString &seri
if (ShellUtils::showPrintDialogAndExit(serializedOptions))
return false;
const QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
// If DBus isn't running, we can't attach to an existing instance.
auto *sessionInterface = QDBusConnection::sessionBus().interface();
if (!sessionInterface)
return false;
const QStringList services = sessionInterface->registeredServiceNames().value();
// Don't match the service without trailing "-" (unique instance)
const QString pattern = QStringLiteral("org.kde.okular-");
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