From 531de16cd0703882e8972bba60c9f295c2d81277 Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Fri, 9 Jul 2021 09:30:58 +0100 Subject: Avoid crashing on startup if DBus isn't running I am trying to run Dolphin 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. --- src/dbusinterface.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/dbusinterface.cpp') diff --git a/src/dbusinterface.cpp b/src/dbusinterface.cpp index 7e453f72a..2b674b968 100644 --- a/src/dbusinterface.cpp +++ b/src/dbusinterface.cpp @@ -20,8 +20,10 @@ DBusInterface::DBusInterface() : { QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this, QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors); - QDBusConnection::sessionBus().interface()->registerService(QStringLiteral("org.freedesktop.FileManager1"), - QDBusConnectionInterface::QueueService); + QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface(); + if (sessionInterface) { + sessionInterface->registerService(QStringLiteral("org.freedesktop.FileManager1"), QDBusConnectionInterface::QueueService); + } } void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId) -- cgit v1.3