Commit 531de16c authored by Alex Richardson's avatar Alex Richardson Committed by Elvis Angelaccio
Browse files

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.
parent d284e22f
......@@ -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)
......
......@@ -1543,7 +1543,8 @@ void DolphinMainWindow::setupActions()
stashSplit->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
stashSplit->setCheckable(false);
stashSplit->setVisible(QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
stashSplit->setVisible(sessionInterface && sessionInterface->isServiceRegistered(QStringLiteral("org.kde.kio.StashNotifier")));
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
......
......@@ -120,7 +120,8 @@ QVector<QPair<QSharedPointer<OrgKdeDolphinMainWindowInterface>, QStringList>> Do
}
// Look for dolphin instances among all available dbus services.
const QStringList dbusServices = QDBusConnection::sessionBus().interface()->registeredServiceNames().value();
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
const QStringList dbusServices = sessionInterface ? sessionInterface->registeredServiceNames().value() : QStringList();
// Don't match the service without trailing "-" (unique instance)
const QString pattern = QStringLiteral("org.kde.dolphin-");
// Don't match the pid without leading "-"
......
Markdown is supported
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