Skip to content

fix: resolve crash when stopping plugins#157

Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
itsXuSt:eagle
Jun 25, 2025
Merged

fix: resolve crash when stopping plugins#157
deepin-bot[bot] merged 1 commit intolinuxdeepin:release/eaglefrom
itsXuSt:eagle

Conversation

@itsXuSt
Copy link
Contributor

@itsXuSt itsXuSt commented Jun 25, 2025

  • Fix crash issue caused by translator instance being deleted while qApp still using it
  • Add .cache and .cursor to .gitignore ignore list

Problem:
When plugins are stopped, the translator instance is deleted with its parent object,
but qApp is still using the instance, causing a crash.

Solution:

  • Optimize translator instance lifecycle management
  • Ensure translator instance is released after qApp stops using it

Task: https://pms.uniontech.com/task-view-378321.html

Summary by Sourcery

Prevent crashes when stopping plugins by re-parenting the translator instance to qApp and update .gitignore

Bug Fixes:

  • Re-parent QTranslator to qApp to ensure it remains alive while qApp uses it, avoiding deletion-related crashes

Chores:

  • Add .cache and .cursor entries to .gitignore

- Fix crash issue caused by translator instance being deleted while qApp still using it
- Add .cache and .cursor to .gitignore ignore list

Problem:
When plugins are stopped, the translator instance is deleted with its parent object,
but qApp is still using the instance, causing a crash.

Solution:
- Optimize translator instance lifecycle management
- Ensure translator instance is released after qApp stops using it

Task: https://pms.uniontech.com/task-view-378321.html
@sourcery-ai
Copy link

sourcery-ai bot commented Jun 25, 2025

Reviewer's Guide

Reparent the QTranslator instance to qApp to prevent premature deletion-related crashes when stopping plugins, and extend .gitignore to exclude .cache and .cursor artifacts.

File-Level Changes

Change Details Files
Reparent translator for correct lifecycle
  • Instantiated QTranslator with qApp instead of plugin
  • Loaded and installed translator as before, now tied to application lifetime
src/dde-file-manager/dfmplugin-cooperation/cooperationplugin.cpp
Extend .gitignore entries
  • Added ".cache" to ignore list
  • Added ".cursor" to ignore list
.gitignore

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

deepin pr auto review

.gitignore 文件修改

  • 新增的 .cursor/*.cache/* 忽略规则可能会影响系统性能,因为忽略这些目录可能会导致系统无法正确缓存和加载光标和缓存文件。建议确认这些目录是否确实不需要被版本控制。
  • 检查 .gitignore 文件中的路径是否正确,避免忽略不应该忽略的文件或目录。

cooperationplugin.cpp 文件修改

  • initialize 函数中,使用 new 关键字创建 QTranslator 对象后,应该考虑使用智能指针(如 std::unique_ptrQScopedPointer)来管理内存,避免内存泄漏。
  • QTranslator 对象的创建使用了 new 关键字,但未在代码中看到相应的删除操作,这可能会导致内存泄漏。建议使用智能指针来管理 QTranslator 对象的生命周期。
  • translator->load 函数中的路径 /usr/share/dde-file-manager/translations 应该是相对于应用程序安装路径的,而不是硬编码的绝对路径。这可以确保在不同环境中都能正确加载翻译文件。

总体来说,代码修改应该能够提高代码的可维护性和性能,但需要注意内存管理以及路径配置的正确性。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: itsXuSt, Johnson-zs

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

@itsXuSt
Copy link
Contributor Author

itsXuSt commented Jun 25, 2025

/merge

@deepin-bot deepin-bot bot merged commit 5031d1e into linuxdeepin:release/eagle Jun 25, 2025
6 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