From 53f7c20cb5b5d5b25a70e072db82921ef2a449d1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 17 Nov 2017 16:33:19 -0800 Subject: Generic Unix Theme: Don't crash if D-Bus is not running Change-Id: I215ef25fe943730ba8b1976695a04a4aa86638f1 Reviewed-by: Shawn Rutledge Reviewed-by: Dmitry Shachnev --- src/platformsupport/themes/genericunix/qgenericunixthemes.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/platformsupport/themes/genericunix') 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() -- cgit v1.2.3