From 3c93dedc063bf453bcda581b4e9ccab5a810c80f Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sun, 28 Apr 2024 12:35:39 +0400 Subject: [PATCH] Check D-Bus tray availability every time It could appear in runtime, this allows applications to watch for it themselves and re-create QSystemTrayIcon as needed. Task-number: QTBUG-94871 Pick-to: 6.7 6.5 Change-Id: I10678cca4238ec0212c69155c9f22c07755ab1a8 Reviewed-by: Dmitry Shachnev Reviewed-by: Shawn Rutledge --- src/gui/platform/unix/qgenericunixthemes.cpp | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/gui/platform/unix/qgenericunixthemes.cpp b/src/gui/platform/unix/qgenericunixthemes.cpp index 53142d81968..8a7f7cd6f7a 100644 --- a/src/gui/platform/unix/qgenericunixthemes.cpp +++ b/src/gui/platform/unix/qgenericunixthemes.cpp @@ -81,15 +81,10 @@ enum { defaultSystemFontSize = 9 }; static bool shouldUseDBusTray() { // There's no other tray implementation to fallback to on non-X11 // and QDBusTrayIcon can register the icon on the fly after creation - static bool result = QGuiApplication::platformName() != "xcb"_L1; - static bool resultKnown = result; - if (!resultKnown) { - QDBusMenuConnection conn; - if (conn.isWatcherRegistered()) - result = true; - resultKnown = true; - qCDebug(qLcTray) << "D-Bus tray available:" << result; - } + if (QGuiApplication::platformName() != "xcb"_L1) + return true; + const bool result = QDBusMenuConnection().isWatcherRegistered(); + qCDebug(qLcTray) << "D-Bus tray available:" << result; return result; } #endif