Skip to content

fix: change static firstLoadFlag to instance member - #866

Merged
deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:agent/bug/b47c77967a40
Oct 27, 2026
Merged

deepin-bot[bot] merged 2 commits into
linuxdeepin:masterfrom
add-uos:agent/bug/b47c77967a40

Conversation

@add-uos

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

Copy link
Copy Markdown
Contributor

fix: change static firstLoadFlag to instance member

  1. Root cause: file-level static bool firstLoadFlag was shared across
    all LoadInfoThread instances, first instance set it false, new
    instances never emit finishedReadFilePool signal again
  2. Fix: replace static firstLoadFlag with instance member m_FirstLoadFlag
    initialized to true in constructor init list, each instance gets
    independent flag for first-load detection
  3. Impact: only LoadInfoThread affected, single-instance usage unchanged,
    multi-instance scenarios now correctly emit signal on first load

Influence:

  1. Test single LoadInfoThread instance emits finishedReadFilePool on
    first load
  2. Test multiple sequential LoadInfoThread instances each emit signal
  3. Verify no regression on device info loading workflow

fix: 将静态 firstLoadFlag 改为实例成员

  1. 根因:文件级 static bool firstLoadFlag 跨所有 LoadInfoThread 实例
    共享,首个实例将其置为 false 后,后续新建实例永远不再 emit
    finishedReadFilePool 信号
  2. 方案:将 static firstLoadFlag 替换为实例成员 m_FirstLoadFlag,在
    构造函数初始化列表中初始化为 true,每个实例拥有独立首次加载标志
  3. 影响:仅影响 LoadInfoThread 实例,单实例场景行为不变,多实例场景
    下首次加载信号正常触发

Influence:

  1. 测试单个 LoadInfoThread 实例首次加载触发 finishedReadFilePool 信号
  2. 测试多个连续 LoadInfoThread 实例各自触发信号
  3. 验证设备信息加载流程无回归

Summary by Sourcery

Bug Fixes:

  • Ensure each LoadInfoThread instance emits the finishedReadFilePool signal during its first load, including when multiple instances are created sequentially.

@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 8 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

The PR fixes missed first-load notifications in multi-instance scenarios by replacing the shared static firstLoadFlag with a per-instance m_FirstLoadFlag, initialized in each LoadInfoThread constructor and consumed when the instance first finishes loading its file pool.

Sequence diagram for per-instance first-load notification

sequenceDiagram
    participant InstanceA as LoadInfoThreadA
    participant PoolA as GetInfoPoolA
    participant InstanceB as LoadInfoThreadB
    participant PoolB as GetInfoPoolB

    InstanceA->>InstanceA: LoadInfoThread()
    InstanceA->>PoolA: finishedAll
    PoolA-->>InstanceA: slotFinishedReadFilePool()
    InstanceA-->>InstanceA: emit finishedReadFilePool()

    InstanceB->>InstanceB: LoadInfoThread()
    InstanceB->>PoolB: finishedAll
    PoolB-->>InstanceB: slotFinishedReadFilePool()
    InstanceB-->>InstanceB: emit finishedReadFilePool()
Loading

File-Level Changes

Change Details Files
Scope the first-load state per LoadInfoThread instance instead of sharing it across all instances.
  • Removed the file-level static flag.
  • Added and constructor-initialized m_FirstLoadFlag.
  • Updated first-load completion handling to use and clear the instance flag.
  • Preserved finishedReadFilePool emission semantics for the first completed load of each instance.
deepin-devicemanager/src/GenerateDevice/LoadInfoThread.cpp
deepin-devicemanager/src/GenerateDevice/LoadInfoThread.h

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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交将静态变量 firstLoadFlag 改为实例成员 m_FirstLoadFlag,修复了多实例共享状态导致后续实例无法触发首次加载信号的逻辑缺陷。变更范围小、目标明确、实现正确,四维度均无问题,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

// 当前实现已正确修复,无需额外修改。
// LoadInfoThread.h 中已声明:
//   bool m_FirstLoadFlag;  //<!  标识是否为首次加载
// LoadInfoThread.cpp 构造函数初始化列表中已初始化:
//   , m_FirstLoadFlag(true)
// slotFinishedReadFilePool 中已正确使用实例成员判断并重置。

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

1. Root cause: file-level static bool firstLoadFlag was shared across
   all LoadInfoThread instances, first instance set it false, new
   instances never emit finishedReadFilePool signal again
2. Fix: replace static firstLoadFlag with instance member m_FirstLoadFlag
   initialized to true in constructor init list, each instance gets
   independent flag for first-load detection
3. Impact: only LoadInfoThread affected, single-instance usage unchanged,
   multi-instance scenarios now correctly emit signal on first load

Influence:
1. Test single LoadInfoThread instance emits finishedReadFilePool on
   first load
2. Test multiple sequential LoadInfoThread instances each emit signal
3. Verify no regression on device info loading workflow

fix: 将静态 firstLoadFlag 改为实例成员

1. 根因:文件级 static bool firstLoadFlag 跨所有 LoadInfoThread 实例
   共享,首个实例将其置为 false 后,后续新建实例永远不再 emit
   finishedReadFilePool 信号
2. 方案:将 static firstLoadFlag 替换为实例成员 m_FirstLoadFlag,在
   构造函数初始化列表中初始化为 true,每个实例拥有独立首次加载标志
3. 影响:仅影响 LoadInfoThread 实例,单实例场景行为不变,多实例场景
   下首次加载信号正常触发

Influence:
1. 测试单个 LoadInfoThread 实例首次加载触发 finishedReadFilePool 信号
2. 测试多个连续 LoadInfoThread 实例各自触发信号
3. 验证设备信息加载流程无回归
The license-check CI (SPDX Header Validation) requires touched sources to
carry a copyright year ending with the current year. Extend the
SPDX-FileCopyrightText header of LoadInfoThread.cpp from 2022 to 2022-2026
so the SPDX summary reports 0 failures.
@add-uos
add-uos force-pushed the agent/bug/b47c77967a40 branch from 19f971b to f2cb05a Compare October 27, 2026 03:45
@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 27, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit 014a95a into linuxdeepin:master Oct 27, 2026
14 checks passed
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