Skip to content

fix: correct off-by-one error in PageOverview row count - #862

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/bug/c1c497cdd9ab
Oct 26, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
add-uos:agent/bug/c1c497cdd9ab

Conversation

@add-uos

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

Copy link
Copy Markdown
Contributor

fix: correct off-by-one error in PageOverview row count

  1. Root cause: PageOverview::updateInfo called setColumnAndRow(row - 1)
    where row equals map.size(), causing table rows to be N-1 instead of
    N+1; the last data row index fell outside valid range and was silently
    dropped by Qt
  2. Fix: change setColumnAndRow(row - 1) to setColumnAndRow(row + 1) to
    reserve one extra row for the expand/collapse button, matching
    PageSingleInfo and PageBoardInfo usage
  3. Impact: single-entry maps no longer show empty tables; all entries
    display correctly in the overview table for both single and multi
    entry scenarios

Log: Fix overview table showing empty or missing last row

Influence:

  1. Test overview page with single device entry to verify table is not empty
  2. Test overview page with multiple device entries to verify all rows display
  3. Verify expand/collapse button still works correctly on overview page

fix: 修复概览页表格行数差一错误

  1. 根因:PageOverview::updateInfo 调用 setColumnAndRow(row - 1),其中
    row 等于 map.size(),导致表格行数为 N-1 而非 N+1;最后一行数据
    索引超出有效范围被 Qt 静默丢弃
  2. 方案:将 setColumnAndRow(row - 1) 改为 setColumnAndRow(row + 1),
    预留一行用于展开/收起按钮,与 PageSingleInfo 和 PageBoardInfo 用法一致
  3. 影响:单条目 map 不再显示空表格;多条目场景下所有条目均能正确显示

Log: 修复概览页表格显示为空或末行丢失的问题

Influence:

  1. 测试单设备条目下概览页表格非空
  2. 测试多设备条目下概览页所有行均显示
  3. 验证概览页展开/收起按钮功能正常

PMS: BUG-3

Summary by Sourcery

Bug Fixes:

  • Correct the overview table row count so single-entry and multi-entry data displays all entries without dropping the final row.

1. Root cause: PageOverview::updateInfo called setColumnAndRow(row - 1)
   where row equals map.size(), causing table rows to be N-1 instead of
   N+1; the last data row index fell outside valid range and was silently
   dropped by Qt
2. Fix: change setColumnAndRow(row - 1) to setColumnAndRow(row + 1) to
   reserve one extra row for the expand/collapse button, matching
   PageSingleInfo and PageBoardInfo usage
3. Impact: single-entry maps no longer show empty tables; all entries
   display correctly in the overview table for both single and multi
   entry scenarios

Log: Fix overview table showing empty or missing last row

Influence:
1. Test overview page with single device entry to verify table is not empty
2. Test overview page with multiple device entries to verify all rows display
3. Verify expand/collapse button still works correctly on overview page

fix: 修复概览页表格行数差一错误

1. 根因:PageOverview::updateInfo 调用 setColumnAndRow(row - 1),其中
   row 等于 map.size(),导致表格行数为 N-1 而非 N+1;最后一行数据
   索引超出有效范围被 Qt 静默丢弃
2. 方案:将 setColumnAndRow(row - 1) 改为 setColumnAndRow(row + 1),
   预留一行用于展开/收起按钮,与 PageSingleInfo 和 PageBoardInfo 用法一致
3. 影响:单条目 map 不再显示空表格;多条目场景下所有条目均能正确显示

Log: 修复概览页表格显示为空或末行丢失的问题

Influence:
1. 测试单设备条目下概览页表格非空
2. 测试多设备条目下概览页所有行均显示
3. 验证概览页展开/收起按钮功能正常

PMS: BUG-3
@sourcery-ai

sourcery-ai Bot commented Oct 22, 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 9 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

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

Reviewer's Guide

Fixes an off-by-one error in PageOverview::updateInfo by allocating map.size() + 1 rows, allowing all overview entries to display and preserving the expand/collapse control row.

Sequence diagram for overview table row allocation

sequenceDiagram
    participant Caller
    participant PageOverview
    participant OverviewTable
    Caller->>PageOverview: updateInfo(map)
    PageOverview->>OverviewTable: setColumnAndRow(map.size() + 1)
    OverviewTable-->>PageOverview: Reserve data rows and control row
    PageOverview->>OverviewTable: Populate overview entries
    PageOverview->>OverviewTable: Populate expand/collapse control row
Loading

File-Level Changes

Change Details Files
Correct the overview table row allocation so every device entry can be rendered while retaining the control row.
  • Replace the row count calculation from row - 1 to row + 1.
  • Reserve an additional row for the expand/collapse button, consistent with related page implementations.
  • Ensure single-entry and multi-entry overview tables no longer omit or drop data rows.
deepin-devicemanager/src/Page/PageOverview.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 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 PageOverview 中表格行数的 off-by-one 错误,将 setColumnAndRow(row - 1) 改为 setColumnAndRow(row + 1),消除了原代码中行数不足导致的潜在越界风险。四维度均通过,无安全漏洞,代码质量良好。仅建议将 row + 1 调整为 row 以避免多余的空行。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: ['建议将 mp_Overview->setColumnAndRow(row + 1) 改为 mp_Overview->setColumnAndRow(row),使表格行数精确匹配实际数据条目数,避免 UI 中出现多余的空行']


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

// 设置表格行数
mp_Overview->setColumnAndRow(row);

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

@deepin-ci-robot

Copy link
Copy Markdown

[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.

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

@add-uos

add-uos commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit eb6004e into linuxdeepin:master Oct 26, 2026
17 checks passed
deepin-bot Bot pushed a commit that referenced this pull request Oct 27, 2026
PR #862 corrected the off-by-one in PageOverview::updateInfo
(setColumnAndRow(row - 1) -> row + 1) after the rewritten PageOverview
tests had already been merged, leaving updateInfo_emptyMap_rowMinusOne
pinning the old buggy semantics: with an empty map the stub now receives
1 instead of -1, so that case fails on current master.

Rename the case to updateInfo_emptyMap_passesRowPlusOne, assert the fixed
semantics (g_colRow == 1) and refresh the stale row-1 comments in the
related cases. All 107 Page-suite cases (PageSingleInfo 39, PageMultiInfo
34, PageOverview 17, PageBoardInfo 17) pass on current master.

Log: 修正 PageOverview 空表用例预期, 与 row+1 修复语义对齐
Influence: 仅测试代码, 不影响业务逻辑
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.

3 participants