Skip to content

Conversation

@csfercoci
Copy link

@csfercoci csfercoci commented Oct 9, 2025

Fix: Resolve memory leaks and improve stability in dde-shell

This commit addresses several critical issues to improve the long-term stability and performance of the Deepin Desktop Environment shell and dock.

  1. Memory Leak in dockdbusproxy.cpp: Fixed a memory leak where a QTimer was allocated without a parent, preventing it from being properly garbage collected. It is now correctly parented.

  2. Memory Leak in rolegroupmodel.cpp: Fixed a memory leak caused by raw pointers to QList<int> in a QHash. A destructor has been added to RoleGroupModel to ensure this memory is deallocated.

  3. Dock Freezing in dockpanel.cpp: Replaced an unreliable QTimer::singleShot with a more robust QMetaObject::invokeMethod using a QueuedConnection. This makes the handling of screen changes safer and should prevent the dock from freezing.

  4. Performance Issue in InWindowBlur.qml: Replaced the resource-intensive MultiEffect component with the more lightweight and efficient FastBlur. This directly addresses performance degradation and potential memory leaks when window blur effects are enabled.

Summary by Sourcery

Resolve several memory leaks and improve stability and performance in the dde-shell and dock components

Bug Fixes:

  • Parent the QTimer in DockDBusProxy to ensure proper lifetime management
  • Add destructor to RoleGroupModel to delete stored QList pointers and clear internal maps

Enhancements:

  • Use QMetaObject::invokeMethod with Qt::QueuedConnection instead of QTimer::singleShot to prevent dock freezing on screen changes
  • Replace the resource-heavy MultiEffect with FastBlur in InWindowBlur.qml for more efficient window blur effects

The `MultiEffect` component was identified as a potential source of memory leaks and performance issues when window blur effects are enabled. This change replaces `MultiEffect` with the more lightweight and efficient `FastBlur` component. This should reduce memory consumption and improve performance, addressing the user's report of a memory leak.
This commit addresses two issues:

1.  A potential memory leak and performance degradation when window blur effects are enabled. This is fixed by replacing the `MultiEffect` QML component with the more lightweight and efficient `FastBlur` in `InWindowBlur.qml`.

2.  A potential freezing issue in the dde-dock, which was likely caused by an unreliable `QTimer::singleShot` used to handle screen changes. This is fixed by replacing the timer with a more robust `QMetaObject::invokeMethod` call with a `QueuedConnection` in `dockpanel.cpp`.
This commit addresses two issues:

1.  A potential memory leak and performance degradation when window blur effects are enabled. This is fixed by replacing the `MultiEffect` QML component with the more lightweight and efficient `FastBlur` in `InWindowBlur.qml`.

2.  A potential freezing issue in the dde-dock, which was likely caused by an unreliable `QTimer::singleShot` used to handle screen changes. This is fixed by replacing the timer with a more robust `QMetaObject::invokeMethod` call with a `QueuedConnection` in `dockpanel.cpp`.
This commit addresses several critical issues to improve the long-term stability and performance of the Deepin Desktop Environment shell and dock.

1.  **Memory Leak in `dockdbusproxy.cpp`**: Fixed a memory leak where a `QTimer` was allocated without a parent, preventing it from being properly garbage collected. It is now correctly parented.

2.  **Memory Leak in `rolegroupmodel.cpp`**: Fixed a memory leak caused by raw pointers to `QList<int>` in a `QHash`. A destructor has been added to `RoleGroupModel` to ensure this memory is deallocated.

3.  **Dock Freezing in `dockpanel.cpp`**: Replaced an unreliable `QTimer::singleShot` with a more robust `QMetaObject::invokeMethod` using a `QueuedConnection`. This makes the handling of screen changes safer and should prevent the dock from freezing.

4.  **Performance Issue in `InWindowBlur.qml`**: Replaced the resource-intensive `MultiEffect` component with the more lightweight and efficient `FastBlur`. This directly addresses performance degradation and potential memory leaks when window blur effects are enabled.
@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: csfercoci

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

@deepin-ci-robot
Copy link

Hi @csfercoci. Thanks for your PR. 😃

@deepin-ci-robot
Copy link

Hi @csfercoci. Thanks for your PR.

I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@github-actions
Copy link

github-actions bot commented Oct 9, 2025

CLA Assistant Lite bot:

如果你是以企业贡献者的身份进行提交,请联系我们签署企业贡献者许可协议
If you submit as corporate contributor, please contact us to sign our Corporate Contributor License Agreement

感谢您的提交,我们非常感谢。 像许多开源项目一样,在接受您的贡献之前,我们要求您签署我们的个人贡献者许可协议。 您只需发布与以下格式相同的评论即可签署个人贡献者许可协议
Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Individual Contributor License Agreement before we can accept your contribution. You can sign the Individual Contributor License Agreement by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA.

You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 9, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR resolves multiple memory leaks and stability issues by correctly parenting timers, adding destructors for dynamic allocations, replacing unreliable timer calls with queued invocations, and optimizing a QML blur effect component.

Sequence diagram for improved dock screen change handling

sequenceDiagram
participant DockPanel
participant Window

DockPanel->>Window: Check m_dockScreen vs window()->screen()
alt m_dockScreen != window()->screen()
    DockPanel->>DockPanel: QMetaObject::invokeMethod(..., Qt::QueuedConnection)
    DockPanel->>Window: setScreen(m_dockScreen)
    DockPanel->>DockPanel: onWindowGeometryChanged()
else
    DockPanel->>DockPanel: onWindowGeometryChanged()
end
Loading

File-Level Changes

Change Details Files
Fix memory leak by parenting QTimer properly
  • Instantiate QTimer with a parent (this)
  • Remove orphaned timer allocation
panels/dock/dockdbusproxy.cpp
Add destructor to RoleGroupModel to free dynamic memory
  • Declare and implement ~RoleGroupModel
  • Use qDeleteAll and clear containers in destructor
panels/dock/taskmanager/rolegroupmodel.cpp
panels/dock/taskmanager/rolegroupmodel.h
Replace singleShot timer with queued method invocation to prevent freezing
  • Switch QTimer::singleShot to QMetaObject::invokeMethod
  • Use Qt::QueuedConnection for deferred screen-change handling
panels/dock/dockpanel.cpp
Improve blur performance by switching to fast blur
  • Swap MultiEffect component for FastBlur
  • Adjust blur parameters (radius) and remove unused properties
shell/InWindowBlur.qml

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 there - I've reviewed your changes - here's some feedback:

  • Replace raw pointer-based data structures in RoleGroupModel with value-based containers (e.g. QVector) to eliminate manual memory management and qDeleteAll calls.
  • Verify that FastBlur in InWindowBlur.qml fully matches the visual and performance characteristics of the original MultiEffect, potentially parameterizing key blur settings instead of hardcoding.
  • In DockPanel, you could simplify the delayed screen update by using a parented QTimer::singleShot call or a named slot instead of QMetaObject::invokeMethod with a lambda to improve readability.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Replace raw pointer-based data structures in RoleGroupModel with value-based containers (e.g. QVector<int>) to eliminate manual memory management and qDeleteAll calls.
- Verify that FastBlur in InWindowBlur.qml fully matches the visual and performance characteristics of the original MultiEffect, potentially parameterizing key blur settings instead of hardcoding.
- In DockPanel, you could simplify the delayed screen update by using a parented QTimer::singleShot call or a named slot instead of QMetaObject::invokeMethod with a lambda to improve readability.

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.

…m stability and performance of the Deepin Desktop Environment shell and dock.

1.  **Refactor `RoleGroupModel` for Memory Safety**: Replaced raw pointer-based containers with value-based `QHash` and `QList`. This eliminates manual memory management (`new`/`delete`) and resolves a class of memory leaks.

2.  **Fix `QTimer` Memory Leak in `dockdbusproxy.cpp`**: Ensured a `QTimer` is parented, allowing Qt's memory management to handle its destruction and preventing a leak.

3.  **Improve Dock Stability in `dockpanel.cpp`**: Refactored the screen change handler to use a zero-delay `QTimer::singleShot`. This provides a safe, deferred execution for the screen update, improving readability and preventing potential freezes.

4.  **Enhance Performance in `InWindowBlur.qml`**: Replaced the resource-intensive `MultiEffect` with the more lightweight and efficient `FastBlur` to address performance degradation and potential memory leaks when window blur effects are enabled.
…m stability and performance of the Deepin Desktop Environment shell and dock.

1.  **Refactor `RoleGroupModel` for Memory Safety**: Replaced raw pointer-based containers with value-based `QHash` and `QList`. This eliminates manual memory management (`new`/`delete`) and resolves a class of memory leaks.

2.  **Fix `QTimer` Memory Leak in `dockdbusproxy.cpp`**: Ensured a `QTimer` is parented, allowing Qt's memory management to handle its destruction and preventing a leak.

3.  **Improve Dock Stability in `dockpanel.cpp`**: Refactored the screen change handler to use a zero-delay `QTimer::singleShot`. This provides a safe, deferred execution for the screen update, improving readability and preventing potential freezes.

4.  **Enhance Performance in `InWindowBlur.qml`**: Replaced the resource-intensive `MultiEffect` with the more lightweight and efficient `FastBlur` to address performance degradation and potential memory leaks when window blur effects are enabled.
@csfercoci csfercoci closed this Oct 9, 2025
}

void RoleGroupModel::adjustMap(int base, int offset)
void RoleGroup_model::adjustMap(int base, int offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

是不是误操作?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants