Skip to content

fix: change firstLoadFlag to instance member - #864

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

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

Conversation

@add-uos

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

Copy link
Copy Markdown
Contributor

fix: change firstLoadFlag to instance member

  1. Root cause: file-level static firstLoadFlag was shared across all
    LoadInfoThread instances, second instance never emits
    finishedReadFilePool signal
  2. Fix: replace static firstLoadFlag with instance member
    m_FirstLoadFlag initialized to true in constructor
  3. Impact: single-instance production behavior unchanged, fixes
    multi-instance signal loss in unit tests

Influence:

  1. Verify device info loads correctly on first launch
  2. Verify finishedReadFilePool signal triggers early refresh
  3. Verify no regression in device display after loading

fix: 将 firstLoadFlag 改为实例成员

  1. 根因:文件级 static firstLoadFlag 被所有 LoadInfoThread 实例共享,
    第二个实例不再 emit finishedReadFilePool 信号
  2. 方案:将 static firstLoadFlag 替换为实例成员 m_FirstLoadFlag,
    在构造函数初始化列表中初始化为 true
  3. 影响:单实例生产环境行为不变,修复单元测试多实例场景信号丢失

Influence:

  1. 验证首次启动时设备信息正确加载
  2. 验证 finishedReadFilePool 信号触发早期刷新
  3. 验证加载后设备显示无回归

PMS: BUG-DEF-004

Summary by Sourcery

Fix LoadInfoThread first-load signaling so newly created instances independently trigger device information refreshes.

Bug Fixes:

  • Ensure each LoadInfoThread instance emits finishedReadFilePool after its first file-pool load, preventing device database refreshes from being skipped in multi-instance scenarios.

Enhancements:

  • Make the first-load state instance-scoped while preserving existing single-instance behavior.

1. Root cause: file-level static firstLoadFlag was shared across all
   LoadInfoThread instances, second instance never emits
   finishedReadFilePool signal
2. Fix: replace static firstLoadFlag with instance member
   m_FirstLoadFlag initialized to true in constructor
3. Impact: single-instance production behavior unchanged, fixes
   multi-instance signal loss in unit tests

Influence:
1. Verify device info loads correctly on first launch
2. Verify finishedReadFilePool signal triggers early refresh
3. Verify no regression in device display after loading

fix: 将 firstLoadFlag 改为实例成员

1. 根因:文件级 static firstLoadFlag 被所有 LoadInfoThread 实例共享,
   第二个实例不再 emit finishedReadFilePool 信号
2. 方案:将 static firstLoadFlag 替换为实例成员 m_FirstLoadFlag,
   在构造函数初始化列表中初始化为 true
3. 影响:单实例生产环境行为不变,修复单元测试多实例场景信号丢失

Influence:
1. 验证首次启动时设备信息正确加载
2. 验证 finishedReadFilePool 信号触发早期刷新
3. 验证加载后设备显示无回归

PMS: BUG-DEF-004
@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 10 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 22, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR fixes cross-instance loss of the first finishedReadFilePool signal by changing first-load tracking from a file-level static variable to a constructor-initialized LoadInfoThread member, preserving single-instance behavior while allowing each new instance to trigger its initial refresh.

Sequence diagram for per-instance initial file-load refresh

sequenceDiagram
    participant A as LoadInfoThread_A
    participant P as GetInfoPool
    participant W as MainWindow
    participant B as LoadInfoThread_B

    P->>A: finishedAll
    A->>A: slotFinishedReadFilePool
    A->>W: finishedReadFilePool
    W->>W: refreshDataBaseLater

    P->>B: finishedAll
    B->>B: slotFinishedReadFilePool
    B->>W: finishedReadFilePool
    W->>W: refreshDataBaseLater
Loading

File-Level Changes

Change Details Files
Make the first-load emission state per LoadInfoThread instance instead of shared at file scope.
  • Remove the file-level static flag.
  • Add and initialize the instance flag to true in the constructor.
  • Use the instance flag when emitting finishedReadFilePool.
deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp
deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h
Document the root cause, affected execution path, and validation considerations for the multi-instance signal-loss bug.
  • Describe how shared state suppresses signaling for subsequent instances.
  • Capture the downstream database refresh impact and relevant production/test paths.
  • Record verification targets for initial loading, early refresh, and device display behavior.
deepin-devicemanager/.pms/bugs/DEF-004/analysis-report.md

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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将 LoadInfoThread 中文件级 static 变量 firstLoadFlag 改为实例成员 m_FirstLoadFlag,正确修复了跨实例共享导致后续实例不 emit finishedReadFilePool 信号的逻辑缺陷。改动范围小(2 个源文件 4 处修改 + 1 个分析报告文档),语法正确、逻辑清晰,无安全漏洞,无性能影响,代码质量良好。四维度均通过,OCR 审查亦无问题。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例


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

@add-uos add-uos closed this Oct 27, 2026
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