summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/themes/genericunix
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@qt.io>2017-11-17 16:33:19 -0800
committerGabriel de Dietrich <gabriel.dedietrich@qt.io>2017-11-20 22:22:18 +0000
commit53f7c20cb5b5d5b25a70e072db82921ef2a449d1 (patch)
treeff7777ca9dd2ea86ce01d2e263256e498f05692b /src/platformsupport/themes/genericunix
parentba2f3a156ebc9ce3e6b6e59e231a5c2847163671 (diff)
Generic Unix Theme: Don't crash if D-Bus is not running
Change-Id: I215ef25fe943730ba8b1976695a04a4aa86638f1 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Dmitry Shachnev <mitya57@gmail.com>
Diffstat (limited to 'src/platformsupport/themes/genericunix')
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index 323e8fd13b..4e7421e98f 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -120,9 +120,11 @@ static bool isDBusTrayAvailable() {
#ifndef QT_NO_DBUS
static bool checkDBusGlobalMenuAvailable()
{
- QDBusConnection connection = QDBusConnection::sessionBus();
- QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar");
- return connection.interface()->isServiceRegistered(registrarService);
+ const QDBusConnection connection = QDBusConnection::sessionBus();
+ static const QString registrarService = QStringLiteral("com.canonical.AppMenu.Registrar");
+ if (const auto iface = connection.interface())
+ return iface->isServiceRegistered(registrarService);
+ return false;
}
static bool isDBusGlobalMenuAvailable()