mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
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.
This commit is contained in:
parent
d284e22f87
commit
531de16cd0
|
@ -20,8 +20,10 @@ DBusInterface::DBusInterface() :
|
||||||
{
|
{
|
||||||
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this,
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/freedesktop/FileManager1"), this,
|
||||||
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
QDBusConnection::ExportScriptableContents | QDBusConnection::ExportAdaptors);
|
||||||
QDBusConnection::sessionBus().interface()->registerService(QStringLiteral("org.freedesktop.FileManager1"),
|
QDBusConnectionInterface *sessionInterface = QDBusConnection::sessionBus().interface();
|
||||||
QDBusConnectionInterface::QueueService);
|
if (sessionInterface) {
|
||||||
|
sessionInterface->registerService(QStringLiteral("org.freedesktop.FileManager1"), QDBusConnectionInterface::QueueService);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DBusInterface::ShowFolders(const QStringList& uriList, const QString& startUpId)
|
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->setToolTip(i18nc("@info", "Opens the stash virtual directory in a split window"));
|
||||||
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
|
stashSplit->setIcon(QIcon::fromTheme(QStringLiteral("folder-stash")));
|
||||||
stashSplit->setCheckable(false);
|
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);
|
connect(stashSplit, &QAction::triggered, this, &DolphinMainWindow::toggleSplitStash);
|
||||||
|
|
||||||
KStandardAction::redisplay(this, &DolphinMainWindow::reloadView, actionCollection());
|
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.
|
// 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)
|
// Don't match the service without trailing "-" (unique instance)
|
||||||
const QString pattern = QStringLiteral("org.kde.dolphin-");
|
const QString pattern = QStringLiteral("org.kde.dolphin-");
|
||||||
// Don't match the pid without leading "-"
|
// Don't match the pid without leading "-"
|
||||||
|
|
Loading…
Reference in a new issue