Skip to content

fix: Fix crash issue if network disconnected.#626

Merged
re2zero merged 2 commits intolinuxdeepin:masterfrom
re2zero:bugfix
Apr 29, 2025
Merged

fix: Fix crash issue if network disconnected.#626
re2zero merged 2 commits intolinuxdeepin:masterfrom
re2zero:bugfix

Conversation

@re2zero
Copy link
Contributor

@re2zero re2zero commented Apr 28, 2025

When device item update after network disconnected, it crashed.

Log: Fix crash issue if network disconnected.
Bug: https://pms.uniontech.com/bug-view-311269.html

Summary by Sourcery

Prevent crash in DeviceItem when network disconnects during operation update.

Bug Fixes:

  • Avoid updating operations on a DeviceItem if it is no longer visible, such as after network disconnection.
  • Ensure proper resource cleanup in the DeviceItem destructor.

When device item update after network disconnected, it crashed.

Log: Fix crash issue if network disconnected.
Bug: https://pms.uniontech.com/bug-view-311269.html
@sourcery-ai
Copy link

sourcery-ai bot commented Apr 28, 2025

Reviewer's Guide by Sourcery

This pull request addresses a crash that occurred when updating device items after a network disconnection. The fix involves adding checks for widget visibility before updating operations and performing necessary cleanup in the destructor.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Added cleanup and signal disconnection in the DeviceItem destructor.
  • Reset the devInfo pointer.
  • Disconnected the buttonClicked signal from the onButtonClicked slot.
src/lib/cooperation/core/gui/widgets/deviceitem.cpp
Added a visibility check before updating operations.
  • Added a check to return early if the device item is not visible in the updateOperations method.
src/lib/cooperation/core/gui/widgets/deviceitem.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

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @re2zero - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider preventing calls to updateOperations entirely when the device item is removed or disconnected, rather than checking visibility within the function.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

v1.1.2 release.

Log: New tag v1.1.2
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. .gitignore 文件修改:

    • 新增的 .cache/ 目录是否确实不需要被版本控制,如果不需要,应该确认是否有其他地方会生成缓存文件,并确保这些文件不会被提交。
  2. debian/changelog 文件修改:

    • 新增的版本更新日志条目格式正确,但建议检查是否有必要在每次小版本更新时都添加新条目,特别是如果只是修复了一个小的崩溃问题。
    • 日期和时间格式是否正确,应该使用 date 命令生成,以确保一致性。
  3. src/lib/cooperation/core/gui/widgets/deviceitem.cpp 文件修改:

    • DeviceItem::~DeviceItem() 析构函数中,devInfo.reset();disconnect(btnBoxWidget, &ButtonBoxWidget::buttonClicked, this, &DeviceItem::onButtonClicked); 是合理的资源清理和信号槽断开操作。
    • updateOperations() 函数中添加了对 isVisible() 的检查,这是一个好的实践,可以避免在设备项不可见时执行不必要的操作,但需要确认这个检查是否适用于所有可能的情况,以及是否有必要在每次更新操作时都进行这个检查。

总体来说,代码修改看起来是合理的,但需要进一步确认新增的 .cache/ 目录是否确实不需要被版本控制,以及 debian/changelog 文件中的日期和时间格式是否正确。

@github-actions
Copy link

TAG Bot

TAG: 1.1.2
EXISTED: no
DISTRIBUTION: unstable

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lzwind, re2zero

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

@re2zero re2zero merged commit 95ba4f4 into linuxdeepin:master Apr 29, 2025
15 of 17 checks passed
@re2zero re2zero deleted the bugfix branch April 29, 2025 11:51
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