From 41d39012d2f11a74a674a8fab3f241b6c2839f6f Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 13 Apr 2020 13:20:19 +0400 Subject: [PATCH] Synchronize AppMenu availability check with Qt --- .../platform/linux/main_window_linux.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index d11896344..084983d46 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -238,9 +238,13 @@ QIcon TrayIconGen(int counter, bool muted) { bool IsIndicatorApplication() { // Hack for indicator-application, which doesn't handle icons sent across D-Bus: // save the icon to a temp file and set the icon name to that filename. - static const auto IndicatorApplication = [&] { + static const auto IndicatorApplication = [] { const auto interface = QDBusConnection::sessionBus().interface(); + if (!interface) { + return false; + } + const auto ubuntuIndicator = interface->isServiceRegistered( qsl("com.canonical.indicator.application")); @@ -338,10 +342,15 @@ quint32 djbStringHash(QString string) { #ifndef TDESKTOP_DISABLE_DBUS_INTEGRATION bool AppMenuSupported() { - static const auto Available = QDBusInterface( - kAppMenuService.utf16(), - kAppMenuObjectPath.utf16(), - kAppMenuInterface.utf16()).isValid(); + static const auto Available = []() -> bool { + const auto interface = QDBusConnection::sessionBus().interface(); + + if (!interface) { + return false; + } + + return interface->isServiceRegistered(kAppMenuService.utf16()); + }(); return Available; }