-
Notifications
You must be signed in to change notification settings - Fork 28
chore: call SNI ContextMenu() if dbus menu is empty #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
原本 menu 指针判空的位置肯定不会成立,因为 menu() 调用一定会返回一个 有效的 QMenu. 此处因而转为检查 menu 是否为空. 这个提交是在为使用 Xembed to SNI proxy 做准备,尽管不一定实际会使用 这个方案. Log:
Reviewer's guide (collapsed on small PRs)Reviewer's GuideUpdates SNI tray right-click handling to always expect a valid QMenu from the D-Bus menu importer, and to fall back to invoking the SNI ContextMenu() method when the menu is empty instead of treating the menu pointer as nullable. Sequence diagram for updated SNI tray right-click context menu handlingsequenceDiagram
actor User
participant SniTrayProtocolHandler
participant DbusMenuImporter
participant QMenu
participant SniInterface
User->>SniTrayProtocolHandler: right_click_tray_icon()
SniTrayProtocolHandler->>DbusMenuImporter: menu()
DbusMenuImporter-->>SniTrayProtocolHandler: QMenu_instance
SniTrayProtocolHandler->>QMenu: isEmpty()
alt menu_is_empty
SniTrayProtocolHandler->>SniInterface: ContextMenu(0, 0)
SniTrayProtocolHandler-->>User: no_local_menu_shown
else menu_has_items
SniTrayProtocolHandler->>QMenu: setFixedSize(sizeHint())
SniTrayProtocolHandler->>QMenu: winId()
SniTrayProtocolHandler-->>User: show_context_menu()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review我来对这段代码的修改进行审查:
改进建议:
总体来说,这是一个很好的改进,提高了代码的健壮性和可靠性。修改后的代码能够更好地处理边界情况,减少了潜在的崩溃风险。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `plugins/application-tray/sniprotocolhandler.cpp:233-234` </location>
<code_context>
} else if (mouseEvent->button() == Qt::RightButton) {
auto menu = m_dbusMenuImporter->menu();
- if (!menu) return false;
+ Q_CHECK_PTR(menu);
+ if (menu->isEmpty()) {
+ m_sniInter->ContextMenu(0, 0);
+ return false;
</code_context>
<issue_to_address>
**issue (bug_risk):** Using Q_CHECK_PTR instead of the previous null check can cause crashes in release builds.
`Q_CHECK_PTR` is a no-op in release builds, so `menu` can still be null and `menu->isEmpty()` would dereference a null pointer and crash. Keep an explicit null check (e.g. `if (!menu) return false;`) in addition to or instead of `Q_CHECK_PTR`.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| Q_CHECK_PTR(menu); | ||
| if (menu->isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Using Q_CHECK_PTR instead of the previous null check can cause crashes in release builds.
Q_CHECK_PTR is a no-op in release builds, so menu can still be null and menu->isEmpty() would dereference a null pointer and crash. Keep an explicit null check (e.g. if (!menu) return false;) in addition to or instead of Q_CHECK_PTR.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, tsic404 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 |
原本 menu 指针判空的位置肯定不会成立,因为 menu() 调用一定会返回一个
有效的 QMenu. 此处因而转为检查 menu 是否为空.
这个提交是在为使用 Xembed to SNI proxy 做准备,尽管不一定实际会使用
这个方案.
Summary by Sourcery
Bug Fixes: