Skip to content

Commit a7324c7

Browse files
committed
fix: resolve DBUS deadlock in application tray
1. Changed from Qt's DBus interface generation to DTK's asynchronous DBus interface generation for StatusNotifierItem 2. Added DTK Tools dependency to CMakeLists.txt for dtk_add_dbus_interfaces 3. Modified DBus interface generation to use dtk_add_dbus_interfaces for org.kde.StatusNotifierItem.xml 4. Updated include directories to include the local api directory 5. Removed forward declaration of StatusNotifierItem class since it's now generated by DTK 6. Added namespace usage for org::kde in sniprotocolhandler.h The issue was that Qt's synchronous DBus property calls could cause deadlocks in the application tray. By switching to DTK's asynchronous DBus interface generation, property access becomes non-blocking, preventing the deadlock situation. This change specifically targets the StatusNotifierItem interface which was causing the deadlock. Log: Fixed application tray DBus deadlock issue Influence: 1. Test application tray functionality with various system tray applications 2. Verify tray icons load correctly without hanging 3. Test DBus communication with StatusNotifierItem services 4. Monitor system responsiveness when multiple tray applications are running 5. Test tray menu interactions and property updates 6. Verify no regression in tray icon display or functionality fix: 解决应用托盘DBus死锁问题 1. 将StatusNotifierItem的DBus接口生成从Qt改为DTK的异步DBus接口生成 2. 在CMakeLists.txt中添加DTK Tools依赖以使用dtk_add_dbus_interfaces 3. 修改DBus接口生成,对org.kde.StatusNotifierItem.xml使用 dtk_add_dbus_interfaces 4. 更新包含目录以包含本地api目录 5. 移除StatusNotifierItem类的前向声明,因为现在由DTK生成 6. 在sniprotocolhandler.h中添加org::kde命名空间使用 问题在于Qt的同步DBus属性调用可能导致应用托盘死锁。通过切换到DTK的异步 DBus接口生成,属性访问变为非阻塞操作,防止了死锁情况。此更改专门针对导致 死锁的StatusNotifierItem接口。 Log: 修复应用托盘DBus死锁问题 Influence: 1. 测试应用托盘功能与各种系统托盘应用程序 2. 验证托盘图标正确加载且无卡顿 3. 测试与StatusNotifierItem服务的DBus通信 4. 监控运行多个托盘应用程序时的系统响应性 5. 测试托盘菜单交互和属性更新 6. 验证托盘图标显示和功能无回归问题
1 parent 1cd2097 commit a7324c7

4 files changed

Lines changed: 12 additions & 6 deletions

File tree

plugins/application-tray/CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
# SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
#
33
# SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -8,7 +8,7 @@ project(${PLUGIN_NAME})
88

99
find_package(PkgConfig REQUIRED)
1010
find_package(Qt${QT_VERSION_MAJOR} ${REQUIRED_QT_VERSION} REQUIRED Core Gui Widgets DBus)
11-
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED Core Gui Widget)
11+
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED Core Gui Widget Tools)
1212
find_package(KF6WindowSystem 6.6 REQUIRED) # for x11 tray selection owner
1313

1414
pkg_check_modules(X11 REQUIRED IMPORTED_TARGET x11 xcb xcb-image xcb-damage xcb-composite xcb-xfixes xcb-util xcb-shape xtst xcb-xtest xcb-res xcb-ewmh)
@@ -51,10 +51,14 @@ set_source_files_properties(
5151
qt_add_dbus_interfaces(
5252
DBUS_INTERFACES
5353
${CMAKE_CURRENT_SOURCE_DIR}/api/dbus/org.deepin.dde.TrayManager1.xml
54-
${CMAKE_CURRENT_SOURCE_DIR}/api/dbus/org.kde.StatusNotifierItem.xml
5554
${CMAKE_CURRENT_SOURCE_DIR}/api/dbus/org.kde.StatusNotifierWatcher.xml
5655
)
5756

57+
dtk_add_dbus_interfaces(
58+
DBUS_INTERFACES
59+
${CMAKE_CURRENT_SOURCE_DIR}/api/dbus/org.kde.StatusNotifierItem.xml
60+
)
61+
5862
add_library(${PLUGIN_NAME} SHARED
5963
${DBUS_INTERFACES}
6064
${TRAY_SOURCES}
@@ -81,6 +85,7 @@ target_include_directories(${PLUGIN_NAME} PUBLIC
8185
"${CMAKE_SOURCE_DIR}/interfaces/"
8286
"${CMAKE_SOURCE_DIR}/src/tray-wayland-integration/"
8387
"${CMAKE_CURRENT_SOURCE_DIR}/../libdbusmenuqt/"
88+
"${CMAKE_SOURCE_DIR}/plugins/application-tray/api/"
8489
)
8590
set_target_properties(${PLUGIN_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugins/dde-dock)
8691
# 设置执行 make install 时哪个目标应该被 install 到哪个位置

plugins/application-tray/ddeindicatortrayprotocol.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -15,7 +15,6 @@
1515

1616
class QTimer;
1717
class DBusMenuImporter;
18-
class StatusNotifierItem;
1918

2019
namespace tray {
2120
class DDEindicatorProtocolHandler;

plugins/application-tray/sniprotocolhandler.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ SniTrayProtocolHandler::SniTrayProtocolHandler(const QString &sniServicePath, QO
109109
// will get a unique dbus name (number like x.xxxx) and dbus path
110110
m_dbusUniqueName = pair.first.mid(1);
111111
m_sniInter = new StatusNotifierItem(pair.first, pair.second, QDBusConnection::sessionBus(), this);
112+
m_sniInter->setSync(false);
112113
m_dbusMenuImporter = new DBusMenu(pair.first, m_sniInter->menu().path(), this);
113114
m_tooltip->setForegroundRole(QPalette::BrightText);
114115
generateId();

plugins/application-tray/sniprotocolhandler.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
1+
// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd.
22
//
33
// SPDX-License-Identifier: GPL-3.0-or-later
44

@@ -18,6 +18,7 @@ class QTimer;
1818
class DBusMenuImporter;
1919

2020
namespace tray {
21+
using namespace org::kde;
2122
class SniTrayProtocolHandler;
2223
class SniTrayProtocol : public AbstractTrayProtocol
2324
{

0 commit comments

Comments
 (0)