Conversation
When an SNI tray item does not implement the Activate method (e.g. Chromium-based apps like Baidu Netdisk), the left-click DBus call fails silently with no fallback, leaving the tray icon unresponsive. Add QDBusPendingCallWatcher to monitor the Activate call result. On failure, try SecondaryActivate, then fall back to showing the DBus menu or calling ContextMenu. Also check ItemIsMenu property before attempting Activate — items declaring ItemIsMenu=true should show their menu directly. The right-click menu display logic is extracted into showSniMenu() to avoid duplication between right-click and left-click fallback paths. Log: SNI托盘左键点击Activate无响应时增加分级fallback Bug: https://pms.uniontech.com/bug-view-360241.html
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideThe PR makes SNI tray left-click handling resilient by checking menu-only items, asynchronously detecting Activate failures, and applying an Activate → SecondaryActivate → menu fallback chain. It also extracts shared DBus menu presentation logic without changing public APIs or the existing successful-activation and right-click paths. Sequence diagram for resilient SNI tray left-click activationsequenceDiagram
participant User
participant Handler as SniTrayProtocolHandler
participant SNI as StatusNotifierItem
participant Menu as DBusMenu
User->>Handler: MouseButtonRelease LeftButton
alt ItemIsMenu is true
Handler->>SNI: itemIsMenu()
Handler->>Handler: showSniMenu(clickPos)
Handler->>Menu: updateMenu(menu)
Handler->>Menu: show()
else ItemIsMenu is false
Handler->>Handler: tryActivate(clickPos)
Handler->>SNI: Activate(0, 0)
SNI-->>Handler: QDBusPendingCallWatcher finished
alt Activate succeeds
Handler->>Handler: deleteLater()
else Activate fails
Handler->>Handler: trySecondaryActivate(clickPos)
Handler->>SNI: SecondaryActivate(0, 0)
SNI-->>Handler: QDBusPendingCallWatcher finished
alt SecondaryActivate succeeds
Handler->>Handler: deleteLater()
else SecondaryActivate fails
Handler->>Handler: showSniMenu(clickPos)
Handler->>Menu: updateMenu(menu)
Handler->>Menu: show()
end
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugins/application-tray/sniprotocolhandler.cpp" line_range="325-327" />
<code_context>
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->button() == Qt::LeftButton) {
+ if (m_sniInter->itemIsMenu()) {
+ showSniMenu(mouseEvent->pos());
+ return false;
+ }
+
</code_context>
<issue_to_address>
**issue (performance):** `itemIsMenu()` performs a synchronous D-Bus property read from the GUI event-filter path, so an unresponsive or disconnected SNI provider blocks the tray UI until the interface timeout expires before processing the click.
**Triggers:** When the SNI service does not respond to the `ItemIsMenu` property request.
**Suggested fix:** Read and cache `ItemIsMenu` asynchronously during item initialization, or avoid a synchronous property lookup in `eventFilter`.
</issue_to_address>| if (m_sniInter->itemIsMenu()) { | ||
| showSniMenu(mouseEvent->pos()); | ||
| return false; |
There was a problem hiding this comment.
issue (performance): itemIsMenu() performs a synchronous D-Bus property read from the GUI event-filter path, so an unresponsive or disconnected SNI provider blocks the tray UI until the interface timeout expires before processing the click.
Triggers: When the SNI service does not respond to the ItemIsMenu property request.
Suggested fix: Read and cache ItemIsMenu asynchronously during item initialization, or avoid a synchronous property lookup in eventFilter.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✓ (22/25)评价: 语法正确,逻辑清晰 ✓ 潜在问题:
建议:
2. 代码质量 ✓ (22/25)评价: 代码结构清晰,注释完整 ✓ 潜在问题:
建议:
3. 代码性能 ✓ (20/20)评价: 性能良好,资源使用合理 ✓ 潜在问题: 说明:
4. 代码安全 ✓ (30/30)存在0个安全漏洞,安全合规 安全漏洞详情: 漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 说明:
🔧 改进建议代码示例// sniprotocolhandler.h - 添加成员变量防止重入
private:
QPointer<QDBusPendingCallWatcher> m_activateWatcher;
// sniprotocolhandler.cpp - 改进 tryActivate 添加重入保护
void SniTrayProtocolHandler::tryActivate(const QPoint &clickPos)
{
// 取消之前进行中的 watcher
if (m_activateWatcher) {
delete m_activateWatcher;
m_activateWatcher = nullptr;
}
m_activateWatcher = new QDBusPendingCallWatcher(m_sniInter->Activate(0, 0), this);
connect(m_activateWatcher, &QDBusPendingCallWatcher::finished, this, [this, clickPos]() {
QDBusPendingReply<> reply = *m_activateWatcher;
m_activateWatcher->deleteLater();
m_activateWatcher = nullptr;
if (reply.isError()) {
trySecondaryActivate(clickPos);
}
});
}📋 审查总结
审查结论: 本次提交针对 PMS Bug #360241(百度网盘托盘左键点击无响应)进行了有效修复。通过添加 QDBusPendingCallWatcher 监控 Activate 调用结果,并实现分级 fallback 链(Activate → SecondaryActivate → showSniMenu),解决了 Chromium-based 应用未实现 Activate 方法时托盘图标无响应的问题。同时将右键菜单显示逻辑提取为 showSniMenu() 函数,减少了代码重复。代码安全无漏洞,建议后续优化重入保护和代码重复问题。 本报告由 AI 代码审查工具自动生成 |
|
该 BUG 是应用自己的问题,桌面环境层面无需解决 |
根因分析
SNI 托盘左键点击处理(
sniprotocolhandler.cppeventFilter)对ActivateDBus 调用采用发后即忘方式,无错误处理、无 fallback。当应用(如百度网盘,Chromium 系)未实现StatusNotifierItem.Activate方法时,DBus 调用返回org.freedesktop.DBus.Error.UnknownMethod错误后被静默丢弃,导致点击托盘图标无反应。修复方案
ItemIsMenu属性,若为true则直接弹 DBus 菜单(符合 SNI 规范)。QDBusPendingCallWatcher异步监听Activate调用结果。SecondaryActivate→ 失败则弹 DBus 菜单或调用ContextMenu。showSniMenu(),左键 fallback 复用。改动安全评估
this,析构时自动清理影响范围
PMS Bug
https://pms.uniontech.com/bug-view-360241.html
Summary by Sourcery
Improve SNI tray activation reliability by honoring menu items and falling back from Activate to SecondaryActivate and the context menu.
New Features:
Bug Fixes:
Enhancements: