From 36ec7d450c34be3714c1912285e5ac78759926ae Mon Sep 17 00:00:00 2001 From: deepin-ci-robot Date: Tue, 14 Jan 2025 02:08:40 +0000 Subject: [PATCH] sync: from linuxdeepin/qt5integration Synchronize source files from linuxdeepin/qt5integration. Source-pull-request: https://github.com/linuxdeepin/qt5integration/pull/257 --- 3rdparty/qdbustrayicon.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/3rdparty/qdbustrayicon.cpp b/3rdparty/qdbustrayicon.cpp index 0553c39..3605632 100644 --- a/3rdparty/qdbustrayicon.cpp +++ b/3rdparty/qdbustrayicon.cpp @@ -56,10 +56,14 @@ static QString iconTempPath() return QDir::tempPath(); } -static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2") - .arg(QDBusConnection::sessionBus().baseService().replace( - QRegularExpression(QStringLiteral("[\\.:]")), QStringLiteral("_"))); - +// delay to access dbus. +static QString KDEItemFormat() +{ + static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2") + .arg(QDBusConnection::sessionBus().baseService().replace( + QRegularExpression(QStringLiteral("[\\.:]")), QStringLiteral("_"))); + return KDEItemFormat; +} static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher"); static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications"); static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications"); @@ -83,7 +87,7 @@ QDBusTrayIcon::QDBusTrayIcon() , m_menuAdaptor(nullptr) , m_menu(nullptr) , m_notifier(nullptr) - , m_instanceId(KDEItemFormat.arg(instanceCount)) + , m_instanceId(KDEItemFormat().arg(instanceCount)) , m_category(QStringLiteral("ApplicationStatus")) , m_defaultStatus(QStringLiteral("Active")) // be visible all the time. QSystemTrayIcon has no API to control this. , m_status(m_defaultStatus)