┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dbusinterface.cpp
diff options
context:
space:
mode:
authorAlex Richardson <[email protected]>2021-07-09 09:30:58 +0100
committerElvis Angelaccio <[email protected]>2021-07-10 20:18:28 +0000
commit531de16cd0703882e8972bba60c9f295c2d81277 (patch)
tree528415ea2cc50d4318938888d295b603b78f70f8 /src/dbusinterface.cpp
parentd284e22f8730e98336fab515a339143341f55ec1 (diff)
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.
Diffstat (limited to 'src/dbusinterface.cpp')
-rw-r--r--src/dbusinterface.cpp6
1 files changed, 4 insertions, 2 deletions
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)