Repository navigation
fix: add null check, fix progress value and destructor order in devicemanager - #877
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR prevents non-DStyle header-rendering crashes, makes driver-backup progress display the intended 0–100% value, and improves layout lifecycle safety by clearing rebuilt-layout pointers and deleting child layouts before their parents. Sequence diagram for safe driver backup progress updatessequenceDiagram
participant Backup as DriverBackup
participant Widget as DetectedStatusWidget
participant Progress as QProgressBar
Backup->>Widget: setBackingUpDriverUI(progressValue, ...)
Widget->>Progress: setValue(progressValue)
Note over Progress: Displays the intended 0-100% value
Flow diagram for safe layout rebuilding in hideAllflowchart TD
A["hideAll()"] --> B["delete this.layout()"]
B --> C[Clear layout member pointers]
C --> D[Create replacement layouts]
D --> E[Rebuild UI safely]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
…emanager 1. Add null check after dynamic_cast<DStyle*> in DriverHeaderView::sectionSizeHint to prevent SIGSEGV in non-DStyle environments 2. Remove erroneous * 10 multiplication on progress value in setBackingUpDriverUI so progress bar shows correct percentage 3. Null out layout member pointers after delete in hideAll() to prevent dangling pointers 4. Reorder destructor to delete child layout before parent and unify on DELETE_PTR to prevent use-after-free Log: driver backup progress bar now shows correct percentage; app no longer crashes on exit Influence: 1. Verify driver backup progress bar displays 0-100% correctly 2. Verify app exits cleanly after switching between detect/download/install/backup UI states 3. Verify header column width renders correctly in normal DStyle environment fix: 修复设备管理器空指针崩溃、进度值越界及析构顺序错误 1. 在 DriverHeaderView::sectionSizeHint 中为 dynamic_cast<DStyle*> 添加判空保护,防止非 DStyle 环境下段错误 2. 移除 setBackingUpDriverUI 中对进度值错误的 ×10 乘法,使进度条显示正确百分比 3. 在 hideAll() 中 delete 布局后立即将成员指针置空,防止悬空指针 4. 调整析构函数删除顺序,子布局先于父布局释放,并统一使用 DELETE_PTR,防止 use-after-free Log: 驱动备份进度条现在显示正确百分比;应用退出时不再崩溃 Influence: 1. 验证驱动备份进度条正确显示 0-100% 2. 验证在检测/下载/安装/备份 UI 状态间反复切换后应用正常退出 3. 验证正常 DStyle 环境下表头列宽渲染正常
539b3db to
8dcce1c
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前实现已正确,无需额外修复。建议保持以下防御性写法:
// 1. dynamic_cast 后做空指针检查
DStyle *style = dynamic_cast<DStyle *>(DApplication::style());
if (!style) {
qCWarning(appLog) << "Failed to get DStyle";
return 0;
}
// 2. 重建布局前先置空旧指针,避免悬空指针
delete this->layout();
mp_HLayoutTotal = nullptr;
mp_HLayoutButton = nullptr;
mp_VLayoutLabel = nullptr;
mp_HLayoutLabel = nullptr;
mp_HLayoutTotal = new QHBoxLayout();本报告由 AI 代码审查工具自动生成 |
|
[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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
…emantics The * 10 progress scaling defect in setBackingUpDriverUI was fixed on master (PR #877), so SetBackingUpDriverUI_Called_ProgressScaledByTen asserting the buggy value 50 now fails. Rename it to SetBackingUpDriverUI_Called_ProgressUsesValueAsIs and expect the value written as-is (5). Also refresh stale comments about the unchecked dynamic_cast<DStyle*> now that sectionSizeHint has a null guard. Verified against current master: 136/136 cases pass (36+53+47) and the DetectedStatusWidget suite now exits cleanly.
fix: add null check, fix progress value and destructor order in devicemanager
Log: driver backup progress bar now shows correct percentage; app no longer crashes on exit
Influence:
fix: 修复设备管理器空指针崩溃、进度值越界及析构顺序错误
Log: 驱动备份进度条现在显示正确百分比;应用退出时不再崩溃
Influence:
Summary by Sourcery
Harden device-manager UI lifecycle handling and correct driver backup progress reporting.
Bug Fixes:
Enhancements: