Repository navigation
fix: add null guards and check svg file open in DDropdownMenu - #632
Merged
deepin-bot[bot] merged 1 commit intoOct 8, 2026
Merged
Conversation
- setCurrentAction(): guard against a null m_menu and skip top-level actions that have no submenu before calling menu()->actions(); a submenu-less action (e.g. the 'None' entry) crashed there. - setCurrentTextOnly(): guard m_menu, which is null after deleteMenu()/setMenu(nullptr). - setSvgColor(): check QFile::open() and return an empty pixmap instead of silently rendering a blank arrow icon; drop the unused before_color variable in SetSVGBackColor. Log: Influence: ddropdownmenu widget
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds null guards to dropdown menu selection paths to prevent crashes after menu removal or when actions have no submenu, and makes SVG loading failures observable with a safe empty-pixmap fallback while removing an unused variable. Sequence diagram for guarded dropdown menu selectionsequenceDiagram
participant Caller
participant DDropdownMenu
participant QMenu
participant QAction
Caller->>DDropdownMenu: setCurrentAction(pAct)
alt m_menu is null
DDropdownMenu->>DDropdownMenu: setText(pAct->text())
DDropdownMenu-->>Caller: return
else m_menu exists
DDropdownMenu->>QMenu: actions()
DDropdownMenu->>QAction: setChecked(true)
loop menu actions
DDropdownMenu->>QAction: menu()
alt subMenu is null
DDropdownMenu-->>DDropdownMenu: continue
else subMenu exists
DDropdownMenu->>QMenu: actions()
DDropdownMenu->>QAction: setChecked(false)
end
end
end
Caller->>DDropdownMenu: setCurrentTextOnly(name)
alt m_menu exists
DDropdownMenu->>QMenu: actions()
DDropdownMenu->>DDropdownMenu: setCheckedExclusive(ac,name)
end
DDropdownMenu->>DDropdownMenu: setText(name)
Sequence diagram for SVG loading failure handlingsequenceDiagram
participant Caller
participant DDropdownMenu
participant QFile
Caller->>DDropdownMenu: setSvgColor(color)
DDropdownMenu->>QFile: open(QIODevice::ReadOnly)
alt open succeeds
DDropdownMenu->>QFile: readAll()
DDropdownMenu-->>Caller: colored QPixmap
else open fails
DDropdownMenu->>DDropdownMenu: qWarning()
DDropdownMenu-->>Caller: QPixmap()
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
lzwind
approved these changes
Oct 8, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: add-uos, lzwind 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 |
Contributor
Author
|
/merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
setCurrentAction():menuList[i]->menu()->actions()对menu()无判空——高亮菜单含无子菜单的顶层 action("None"),调用即空指针崩溃(与 ab891dd 在setCurrentTextOnly中修复的 56765 同类缺陷,该方法未同步加固);m_menu本身也无判空。setCurrentTextOnly():m_menu->actions()无m_menu判空——deleteMenu()/setMenu(nullptr)之后调用即崩。setSvgColor():QFile::open无失败处理,资源缺失时静默渲染空白箭头图标;SetSVGBackColor()内before_color赋值后未使用。修复
setCurrentAction():入口对m_menu判空,循环内跳过无子菜单的 action;setCurrentTextOnly():遍历前对m_menu判空(保留setText);setSvgColor():检查open()失败时告警并返回空 pixmap;删除未使用的before_color。背景
该问题由 AI 辅助单测(PMS 缺陷热点补强)读码审查发现。
Summary by Sourcery
Harden DDropdownMenu against null menus and unavailable SVG resources.
Bug Fixes:
Enhancements: