From 9b5eb0d37947efe5da208c6febc3784b81fbfabe Mon Sep 17 00:00:00 2001 From: Ye ShanShan Date: Tue, 14 Jan 2025 10:06:07 +0800 Subject: [PATCH] chore: delay to access dbus for trayicon it effects when dbus can't work. pms: BUG-368399 --- 3rdparty/qdbustrayicon.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/3rdparty/qdbustrayicon.cpp b/3rdparty/qdbustrayicon.cpp index 0553c39f..36056324 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)