Commit 4128e0ba authored by Alex Richardson's avatar Alex Richardson Committed by Nicolas Fella
Browse files

Avoid crashing on startup if DBus isn't running

I am trying to run Gwenview on a minimal FreeBSD CHERI-RISC-V QEMU
instance and I haven't got DBus running. Without this change Gwenview
crashes because QDBusConnection::sessionBus().interface() returns NULL.
parent 0fe6cddb
......@@ -47,15 +47,18 @@ LockScreenWatcher::LockScreenWatcher(QObject *parent)
screenLockServiceWatcher->setWatchMode(QDBusServiceWatcher::WatchForOwnerChange);
screenLockServiceWatcher->addWatchedService(screenSaverServiceName());
auto *watcher = new DBusBoolReplyWatcher(this);
connect(watcher, &DBusBoolReplyWatcher::finished,
this, &LockScreenWatcher::onServiceRegisteredQueried);
connect(watcher, &DBusBoolReplyWatcher::canceled,
watcher, &DBusBoolReplyWatcher::deleteLater);
watcher->setFuture(QtConcurrent::run(QDBusConnection::sessionBus().interface(),
&QDBusConnectionInterface::isServiceRegistered,
screenSaverServiceName()));
if (QDBusConnection::sessionBus().interface()) {
auto *watcher = new DBusBoolReplyWatcher(this);
connect(watcher, &DBusBoolReplyWatcher::finished, this,
&LockScreenWatcher::onServiceRegisteredQueried);
connect(watcher, &DBusBoolReplyWatcher::canceled, watcher,
&DBusBoolReplyWatcher::deleteLater);
watcher->setFuture(
QtConcurrent::run(QDBusConnection::sessionBus().interface(),
&QDBusConnectionInterface::isServiceRegistered,
screenSaverServiceName()));
}
}
LockScreenWatcher::~LockScreenWatcher() = default;
......
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