Skip to content

fix: fix checkLocalFolder ignoring param and remove dead code in paintEvent - #942

Closed
add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/079b1b3d5d37
Closed

add-uos wants to merge 1 commit into
linuxdeepin:masterfrom
add-uos:agent/pms-bug-bot/079b1b3d5d37

Conversation

@add-uos

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

Copy link
Copy Markdown
Contributor

fix: fix checkLocalFolder ignoring param and remove dead code in paintEvent

  1. Root cause: checkLocalFolder(const QString &path) discarded the
    parameter via Q_UNUSED(path) and used member mp_folderPath instead,
    making the API misleading; CmdButtonWidget::paintEvent called
    this->rect().setWidth(808) on a temporary QRect copy, which is
    dead code since the next line achieves the intent correctly
  2. Fix: remove Q_UNUSED(path) and use the path parameter in
    QStorageInfo constructor; remove the dead code line in paintEvent
  3. Impact: checkLocalFolder now validates the actual parameter passed
    by the caller; paintEvent behavior unchanged since the dead line
    had no effect; current callers pass the same value so no behavior
    change in practice

fix: 修复checkLocalFolder忽略形参及移除paintEvent死代码

  1. 根因:checkLocalFolder(const QString &path) 通过 Q_UNUSED(path)
    丢弃形参,实际使用成员 mp_folderPath,导致 API 语义误导;
    CmdButtonWidget::paintEvent 中 this->rect().setWidth(808) 对
    临时 QRect 副本调用,属于死代码,下一行已正确实现相同逻辑
  2. 方案:移除 Q_UNUSED(path),将 QStorageInfo info(mp_folderPath)
    改为 QStorageInfo info(path);移除 paintEvent 中的死代码行
  3. 影响:checkLocalFolder 现在校验实际传入的形参;paintEvent 行为
    不变(死代码行本就无效果);当前调用点传入值与成员相同,实际
    无行为变化

Fixes: #936

Summary by Sourcery

Correct local-folder path validation and remove dead painting code.

Bug Fixes:

  • Make local-folder validation use the path supplied by the caller instead of an unrelated member path.

Enhancements:

  • Remove ineffective rectangle modification code from button painting.

…tEvent

1. Root cause: checkLocalFolder(const QString &path) discarded the
   parameter via Q_UNUSED(path) and used member mp_folderPath instead,
   making the API misleading; CmdButtonWidget::paintEvent called
   this->rect().setWidth(808) on a temporary QRect copy, which is
   dead code since the next line achieves the intent correctly
2. Fix: remove Q_UNUSED(path) and use the path parameter in
   QStorageInfo constructor; remove the dead code line in paintEvent
3. Impact: checkLocalFolder now validates the actual parameter passed
   by the caller; paintEvent behavior unchanged since the dead line
   had no effect; current callers pass the same value so no behavior
   change in practice

fix: 修复checkLocalFolder忽略形参及移除paintEvent死代码

1. 根因:checkLocalFolder(const QString &path) 通过 Q_UNUSED(path)
   丢弃形参,实际使用成员 mp_folderPath,导致 API 语义误导;
   CmdButtonWidget::paintEvent 中 this->rect().setWidth(808) 对
   临时 QRect 副本调用,属于死代码,下一行已正确实现相同逻辑
2. 方案:移除 Q_UNUSED(path),将 QStorageInfo info(mp_folderPath)
   改为 QStorageInfo info(path);移除 paintEvent 中的死代码行
3. 影响:checkLocalFolder 现在校验实际传入的形参;paintEvent 行为
   不变(死代码行本就无效果);当前调用点传入值与成员相同,实际
   无行为变化

Fixes: linuxdeepin#936
@sourcery-ai

sourcery-ai Bot commented Oct 26, 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 1 day and 12 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 26, 2026

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

Reviewer's Guide

The PR corrects checkLocalFolder to validate the path provided by its caller and removes a no-op QRect mutation from paintEvent; rendering behavior remains unchanged, while the validation API now has the intended semantics.

Sequence diagram for caller-provided folder validation

sequenceDiagram
    participant Caller
    participant UrlChooserEdit
    participant QStorageInfo

    Caller->>UrlChooserEdit: checkLocalFolder(path)
    UrlChooserEdit->>QStorageInfo: QStorageInfo(path)
    QStorageInfo-->>UrlChooserEdit: path device information
    UrlChooserEdit->>QStorageInfo: isValid()
    QStorageInfo-->>UrlChooserEdit: validation result
Loading

File-Level Changes

Change Details Files
Make local-folder validation honor the method argument instead of a widget member value.
  • Remove the unused-parameter suppression.
  • Construct QStorageInfo from the supplied path, preserving the existing validity and device checks.
deepin-devicemanager/src/Widget/UrlChooserEdit.cpp
Remove an ineffective geometry mutation from the paint path.
  • Delete the width update applied to a temporary QRect; retain the subsequent update on the local rectangle used for painting.
deepin-devicemanager/src/Widget/CmdButtonWidget.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


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 checkLocalFolder 函数忽略参数的 bug,并移除了 paintEvent 中的无效死代码。两处修改逻辑正确、目标明确,四维度均无问题,OCR 审查也未发现任何缺陷。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: ['无需修改,代码逻辑正确。']


2. 代码质量 ✅

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

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

建议: ['无需修改,代码质量良好。']


3. 代码性能 ✅

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

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

建议: ['无需修改,性能良好。']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: ['无需修改,安全合规。']


💡 改进建议代码示例

本次变更已经是正确的修复,无需额外修改。修复后的代码如下:
// CmdButtonWidget.cpp - paintEvent 中已移除无效的 this->rect().setWidth(808) void CmdButtonWidget::paintEvent(QPaintEvent *event) {
    // ...
    QRect rect = this->rect();
    rect.setWidth(808);
    // 开始绘制边框
    // ...
}
// UrlChooserEdit.cpp - checkLocalFolder 已正确使用 path 参数 void UrlChooserEdit::checkLocalFolder(const QString &path) {
    qCDebug(appLog) << "Checking if folder is local:" << path;
    bool isLocal = true;
    mp_urlEdit->setAlert(false);
    QStorageInfo info(path);                                        //获取路径信息
    qCInfo(appLog) << __func__ << info.device();
    if (!info.isValid() || !info.device().startsWith("/dev/")) {     //判断路径信息是不是本地路径
        qCWarning(appLog) << "Selected folder is not local";
        // ...
    }
}

本报告由 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