Skip to content

Conversation

@wjyrich
Copy link
Contributor

@wjyrich wjyrich commented Nov 12, 2025

  1. Set dynamic sort filter to false in TaskManagerProxyModel constructor
  2. This prevents automatic resorting when source model data changes
  3. Improves performance by reducing unnecessary sorting operations
  4. Maintains stable task ordering in the dock panel

fix: 在任务管理器代理模型中禁用动态排序过滤器

主要问题在于,关闭wine应用窗口,abstractmonitor发出datachanged后,会导致出现一个insert信号, 原因是出现在taskmanager的boolfilter,Qt内部的QSortilter会出发排序,会触发insert信号,从而多了重复窗口被加入。

后续出现相关类型其他问题,比如出现tooltip,popup等等窗口出现在任务栏,可以优先看这里的问题。

PMS: BUG-339345

Summary by Sourcery

Disable dynamic sorting in the task manager proxy model to avoid automatic re-sorting and redundant insert signals on data changes, thereby preventing duplicate entries, boosting performance, and preserving task order.

Bug Fixes:

  • Disable dynamic sort filter in TaskManagerProxyModel to prevent duplicate window entries and unintended insert signals when source data changes.

Enhancements:

  • Improve performance by reducing unnecessary sorting operations and maintain stable task ordering in the dock panel.

1. Set dynamic sort filter to false in TaskManagerProxyModel constructor
2. This prevents automatic resorting when source model data changes
3. Improves performance by reducing unnecessary sorting operations
4. Maintains stable task ordering in the dock panel

fix: 在任务管理器代理模型中禁用动态排序过滤器

主要问题在于,关闭wine应用窗口,abstractmonitor发出datachanged后,会导致出现一个insert信号,
原因是出现在taskmanager的boolfilter,Qt内部的QSortilter会出发排序,会触发insert信号,从而多了重复窗口被加入。

后续出现相关类型其他问题,比如出现tooltip,popup等等窗口出现在任务栏,可以优先看这里的问题。

PMS: BUG-339345
@sourcery-ai
Copy link

sourcery-ai bot commented Nov 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR disables dynamic sorting in the TaskManager proxy model by adding a single call to setDynamicSortFilter(false) in the BoolFilterModel constructor, preventing automatic resorting on source model updates to improve performance and maintain stable task ordering.

Class diagram for updated BoolFilterModel constructor

classDiagram
    class BoolFilterModel {
        +BoolFilterModel(QObject* parent, QAbstractItemModel* sourceModel, int role)
        +setDynamicSortFilter(bool)
    }
    BoolFilterModel --|> QSortFilterProxyModel
    BoolFilterModel --|> AbstractTaskManager
    QSortFilterProxyModel <|-- BoolFilterModel
    AbstractTaskManager <|-- BoolFilterModel
Loading

File-Level Changes

Change Details Files
Disable dynamic sort filter in proxy model initialization
  • Add setDynamicSortFilter(false) call in BoolFilterModel constructor to stop automatic resorting on data changes
panels/dock/taskmanager/taskmanager.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

deepin pr auto review

我来帮你分析这段代码的修改:

  1. 修改内容:
    在 BoolFilterModel 构造函数中添加了 setDynamicSortFilter(false) 的调用。

  2. 代码分析:

  • BoolFilterModel 继承自 QSortFilterProxyModel,这是一个用于过滤和排序的代理模型
  • setDynamicSortFilter() 是 QSortFilterProxyModel 的方法,用于控制是否在源模型改变时自动重新进行过滤和排序
  1. 改进建议:
  • 性能优化:这个修改是合理的。将动态排序过滤设置为 false 可以避免不必要的重复过滤和排序操作,特别是在源模型频繁变化的场景下,可以显著提升性能。
  • 代码质量:建议在添加这行代码时添加注释说明原因,例如:
// 禁用动态排序过滤以提高性能,避免源模型频繁变化时的不必要重计算
setDynamicSortFilter(false);
  1. 安全性:
    这个修改不会引入安全风险,因为:
  • 只是改变了代理模型的行为方式
  • 不会影响数据的完整性
  • 不会导致内存泄漏或其他安全问题
  1. 其他建议:
  • 考虑是否需要在适当的时候手动触发过滤/排序更新
  • 可以考虑在类文档中说明这个设计决策的原因

总的来说,这是一个很好的性能优化改动,但建议添加注释说明原因,以便其他开发者理解这个设计决策。

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 and they look great!


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.

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, wjyrich

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

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where closing Wine application windows causes duplicate window entries in the taskbar. The issue stems from Qt's QSortFilterProxyModel automatically re-sorting when source model data changes, which triggers unexpected insert signals in the BoolFilterModel. The fix disables dynamic sorting to prevent these spurious insert events.

Key changes:

  • Added setDynamicSortFilter(false) to the BoolFilterModel constructor to disable automatic re-filtering/re-sorting on source data changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wjyrich
Copy link
Contributor Author

wjyrich commented Nov 12, 2025

/forcemerge

@deepin-bot
Copy link

deepin-bot bot commented Nov 12, 2025

This pr force merged! (status: behind)

@deepin-bot deepin-bot bot merged commit e6fcc84 into linuxdeepin:master Nov 12, 2025
16 of 17 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