Skip to content

fix: add null check, fix progress value and destructor order in devicemanager - #879

Open
add-uos wants to merge 2 commits into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/932d34bdcf08
Open

add-uos wants to merge 2 commits into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/932d34bdcf08

Conversation

@add-uos

@add-uos add-uos commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

fix: add null check, fix progress value and destructor order in devicemanager

  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 环境下表头列宽渲染正常

Summary by Sourcery

Stabilize device manager UI rendering, progress reporting, and cleanup behavior.

Bug Fixes:

  • Prevent crashes when the application runs without a DStyle instance.
  • Display driver backup progress using the correct 0–100% value.
  • Prevent dangling layout pointers and shutdown use-after-free issues during UI transitions and destruction.

Enhancements:

  • Ensure child layouts are released safely before their parent layouts.

…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 环境下表头列宽渲染正常
@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown

Sorry @add-uos, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 days and 3 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: add-uos

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR hardens device-manager UI lifecycle handling by preventing null-style crashes, correcting backup progress percentages, and fixing layout deletion order and pointer cleanup to avoid dangling-pointer and shutdown failures.

Sequence diagram for safe device-manager UI state switching

sequenceDiagram
    participant UI as DeviceManagerUI
    participant Layout as QLayout
    participant Widget as DetectedStatusWidget

    UI->>Widget: hideAll()
    Widget->>Layout: delete this.layout()
    Widget->>Widget: clear layout member pointers
    Widget->>Layout: create replacement layouts
    UI->>Widget: switch to detect, download, install, or backup UI
Loading

Sequence diagram for corrected driver backup progress

sequenceDiagram
    participant Backup as DriverBackup
    participant UI as DetectedStatusWidget
    participant Progress as QProgressBar

    Backup->>UI: setBackingUpDriverUI(progressValue, totalValue, driverDescription)
    UI->>Progress: setValue(progressValue)
    Progress-->>UI: display progress from 0 to 100
Loading

Flow diagram for null-safe header style sizing

flowchart TD
    Start[sectionSizeHint] --> Cast["dynamic_cast<DStyle *>(DApplication::style())"]
    Cast --> Check{DStyle available?}
    Check -->|No| Warn[Log warning and return 0]
    Check -->|Yes| Metric[Read pixelMetric and calculate column width]
Loading

File-Level Changes

Change Details Files
Added defensive handling for non-DStyle environments when calculating driver table header section widths.
  • Checks the dynamic_cast result before accessing DStyle metrics.
  • Logs a warning and returns a safe fallback when DStyle is unavailable.
deepin-devicemanager/src/Widget/drivertableview.cpp
Corrected backup progress reporting and made layout cleanup safer during UI transitions and destruction.
  • Passes the backup progress value directly to the progress bar instead of multiplying it by 10.
  • Nulls layout member pointers after deleting the active layout in hideAll().
  • Deletes child layouts before parent layouts and consistently uses DELETE_PTR in the destructor.
deepin-devicemanager/src/Widget/DetectedStatusWidget.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了空指针解引用、进度值计算错误、析构器顺序及悬垂指针问题,变更范围小且精准,四个维度均无问题,代码质量优秀。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

本次变更已经是正确的修复方式,无需额外修改代码示例。

本报告由 AI 代码审查工具自动生成

@deepin-bot

deepin-bot Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.0.75
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #956

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants