Skip to content

fix: replace deprecated invalidateFilter with begin/endFilterChange on Qt 6.12 - #1799

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.12-invalidatefilter-deprecated
Nov 6, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
pengfeixx:fix/qt6.12-invalidatefilter-deprecated

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Qt 6.13 deprecates QSortFilterProxyModel::invalidateFilter() in favor of
beginFilterChange()/endFilterChange(), and the Qt 6.12 headers already
provide the new API while enabling the deprecation warning. With
-Werror=deprecated-declarations the build fails on Qt 6.12:

panels/dock/taskmanager/hoverpreviewproxymodel.cpp:25:21: error: 'void QSortFilterProxyModel::invalidateFilter()' is deprecated:
  Use begin/endFilterChange() instead [-Werror=deprecated-declarations]
panels/dock/tray/ksortfilterproxymodel.cpp:249:44: error: (same)

Changes

  • Guard both direct call sites (hoverpreviewproxymodel.cpp:25,
    ksortfilterproxymodel.cpp:249) with a QT_VERSION check:
    beginFilterChange()+endFilterChange() from Qt 6.12 on,
    invalidateFilter() for older baselines (the new API does not exist in
    Qt 6.8, so an unconditional switch would break the current baseline)
  • The other two call sites in ksortfilterproxymodel.cpp go through the
    class' own invalidateFilter() wrapper and are fixed transitively

Testing

  • Qt 6.12 headers: the old call reproduces the exact CI error; the
    gated form compiles clean with -Werror=deprecated-declarations
  • Qt 6.8 headers: the gated form compiles clean (fallback branch)
  • Full package build on the Qt 6.12 RC server

Summary by Sourcery

Bug Fixes:

  • Replace deprecated filter invalidation calls with the Qt 6.12+ filter-change API while retaining compatibility with older Qt versions.

@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026

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

Reviewer's Guide

The PR conditionally migrates direct and wrapped filter invalidation to beginFilterChange()/endFilterChange() on Qt 6.12+, while preserving invalidateFilter() on older Qt versions so both the Qt 6.12 deprecation-as-error build and the current Qt 6.8 baseline remain supported.

Sequence diagram for version-compatible filter changes

sequenceDiagram
    participant Caller
    participant ProxyModel
    participant QtAPI as Qt_filter_API

    Caller->>ProxyModel: setFilter(filter, mode)
    alt Qt 6.12+
        ProxyModel->>QtAPI: beginFilterChange()
        ProxyModel->>QtAPI: endFilterChange()
    else Qt before 6.12
        ProxyModel->>QtAPI: invalidateFilter()
    end
Loading

File-Level Changes

Change Details Files
Replaced deprecated filter invalidation calls with Qt-version-compatible filter-change notifications.
  • Use beginFilterChange()/endFilterChange() when compiling against Qt 6.12 or newer.
  • Retain invalidateFilter() for Qt versions before 6.12.
  • Update the model-specific invalidateFilter() wrapper so indirect callers are covered transitively.
panels/dock/taskmanager/hoverpreviewproxymodel.cpp
panels/dock/tray/ksortfilterproxymodel.cpp
Added compatibility handling for differing Qt API availability across supported baselines.
  • Guard the new API with QT_VERSION checks to avoid breaking Qt 6.8 builds.
  • Address deprecation warnings treated as errors on Qt 6.12.
panels/dock/taskmanager/hoverpreviewproxymodel.cpp
panels/dock/tray/ksortfilterproxymodel.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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="panels/dock/tray/ksortfilterproxymodel.cpp" line_range="253" />
<code_context>
+    // invalidateFilter() is deprecated since Qt 6.13; begin/endFilterChange()
+    // is available from Qt 6.12 and is the replacement
+    beginFilterChange();
+    endFilterChange();
+#else
     invalidateFilter();
</code_context>
<issue_to_address>
**Filtered columns remain stale**

When the column callback changes or is cleared on Qt 6.12 or newer, `setFilterColumnCallback()` calls this wrapper, but `endFilterChange()` defaults to `Rows`, so `filterAcceptsColumn()` is not rerun and callers continue seeing columns filtered by the old callback.

End the filter-change transaction with the `Columns` direction.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@pengfeixx
pengfeixx force-pushed the fix/qt6.12-invalidatefilter-deprecated branch 2 times, most recently from f27b46e to 794d016 Compare November 6, 2026 00:53
@pengfeixx

Copy link
Copy Markdown
Contributor Author

感谢仔细的评审,但这个前提在 Qt 6.12 上不成立:endFilterChange() 的默认方向是 Direction::Both,不是 Rows——

// qsortfilterproxymodel.h(Qt 6.12)
void endFilterChange(Directions directions = Direction::Both);

实现里(QSortFilterProxyModelPrivate::filter_changed,qsortfilterproxymodel.cpp:1299)只要 directions 含 Columns 位就会重跑 filterAcceptsColumn(),因此这里列过滤会被重新求值,不会出现旧回调残留的 stale 列。

弃用注记里出现的 "Direction::Rows/Columns" 字样,是给旧的带方向参数的 invalidateFilter() 重载的迁移提示(旧 Rows 重载 → 提示改用 endFilterChange(Direction::Rows)),并不是无参 endFilterChange() 的默认值。

另外,这个 wrapper(KSortFilterProxyModel::invalidateFilter())同时被 setFilterRowCallback()(第 158 行)调用;如果把这里限定为 Direction::Columns,行回调变更后行过滤反而会 stale。保持默认的 Both 对两个调用方都是正确的。

@pengfeixx
pengfeixx force-pushed the fix/qt6.12-invalidatefilter-deprecated branch from 794d016 to f71f720 Compare November 6, 2026 02:46
…n Qt 6.12

1. Qt 6.13 deprecates QSortFilterProxyModel::invalidateFilter() in
   favor of beginFilterChange()/endFilterChange(), and Qt 6.12 already
   provides the new API while enabling the deprecation warning; with
   -Werror=deprecated-declarations the dock build now fails on
   hoverpreviewproxymodel.cpp:25 and ksortfilterproxymodel.cpp:249.
2. Guard both direct call sites with a QT_VERSION check: use
   beginFilterChange()+endFilterChange() from Qt 6.12 on, and keep
   invalidateFilter() for older baselines (the new API does not exist
   in Qt 6.8).
3. Verified on Qt 6.12 headers: the old call reproduces the exact CI
   error, the gated form compiles clean with
   -Werror=deprecated-declarations; the gated form also compiles
   clean against Qt 6.8 (old branch).

Log: dde-shell dock panels build again with Qt 6.12 and stay
compatible with the Qt 6.8 baseline

Influence:
1. Build the dock and tray panels on Qt 6.12 and confirm no
   deprecated-declarations errors remain
2. Rebuild on the Qt 6.8 baseline and confirm the fallback branch
   compiles unchanged
3. Exercise the taskmanager hover preview and tray filtering to check
   the filter refresh behavior is preserved

fix: Qt 6.12 下以 begin/endFilterChange 替代已废弃的 invalidateFilter

1. Qt 6.13 将 QSortFilterProxyModel::invalidateFilter() 标记废弃,
   改用 beginFilterChange()/endFilterChange();Qt 6.12 已提供新 API
   并默认启用弃用告警,叠加 -Werror=deprecated-declarations 后,
   dock 构建在 hoverpreviewproxymodel.cpp:25 与
   ksortfilterproxymodel.cpp:249 失败。
2. 对两处直接调用点加 QT_VERSION 门控:Qt 6.12 起使用
   beginFilterChange()+endFilterChange(),旧基线(6.8 无新 API)保留
   invalidateFilter()。
3. 已在 Qt 6.12 头文件下验证:旧写法复现 CI 同款错误,门控写法在
   -Werror=deprecated-declarations 下干净编译;门控写法对 Qt 6.8
   亦编译通过(走旧分支)。

Log: dde-shell 的 dock 面板在 Qt 6.12 下恢复可构建,并保持与
Qt 6.8 基线兼容

Influence:
1. 在 Qt 6.12 下构建 dock 与 tray 面板,确认无
   deprecated-declarations 错误
2. 在 Qt 6.8 基线重新构建,确认回退分支编译行为不变
3. 验证任务栏悬停预览与托盘过滤的刷新行为保持正常
@pengfeixx
pengfeixx force-pushed the fix/qt6.12-invalidatefilter-deprecated branch from f71f720 to 91b655b Compare November 6, 2026 02:46
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本PR将Qt 6.12中已废弃的invalidateFilter()替换为beginFilterChange()/endFilterChange(),通过条件编译实现版本兼容。变更简洁正确,无安全漏洞,无逻辑缺陷,代码质量良好。OCR提出一个低优先级可维护性改进建议(将成员变量赋值移至beginFilterChange/endFilterChange之间以符合新API惯用法),但不影响功能正确性。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: ['建议在hoverpreviewproxymodel.cpp的setFilter()方法中,将m_filter和m_filterMode的赋值移至beginFilterChange()和endFilterChange()之间,以充分利用新API避免冗余重新评估的能力']


3. 代码性能 ✅

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

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

建议: ['将成员变量赋值移至beginFilterChange()/endFilterChange()之间可获得新API带来的潜在性能优化']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

// panels/dock/taskmanager/hoverpreviewproxymodel.cpp
// 建议将成员变量赋值移至 beginFilterChange()/endFilterChange() 之间
void HoverPreviewProxyModel::setFilter(QString filter, enum FilterMode mode)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 12, 0)
    beginFilterChange();
    m_filter = filter;
    m_filterMode = mode;
    endFilterChange();
#else
    m_filter = filter;
    m_filterMode = mode;
    invalidateFilter();
#endif
}

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy, pengfeixx

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

@mhduiy

mhduiy commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 6, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 49194d9 into linuxdeepin:master Nov 6, 2026
7 of 10 checks passed
@pengfeixx
pengfeixx deleted the fix/qt6.12-invalidatefilter-deprecated branch November 6, 2026 03:34
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