From 91b655b11319f365654c13ddd9a07d9f4b34ff5a Mon Sep 17 00:00:00 2001 From: pengfeixx <63588879+pengfeixx@users.noreply.github.com> Date: Fri, 6 Nov 2026 08:47:35 +0800 Subject: [PATCH] fix: replace deprecated invalidateFilter with begin/endFilterChange on Qt 6.12 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 验证任务栏悬停预览与托盘过滤的刷新行为保持正常 --- panels/dock/taskmanager/hoverpreviewproxymodel.cpp | 7 ++++++- panels/dock/tray/ksortfilterproxymodel.cpp | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/panels/dock/taskmanager/hoverpreviewproxymodel.cpp b/panels/dock/taskmanager/hoverpreviewproxymodel.cpp index 69c1b4273..014502643 100644 --- a/panels/dock/taskmanager/hoverpreviewproxymodel.cpp +++ b/panels/dock/taskmanager/hoverpreviewproxymodel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025-2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -22,7 +22,12 @@ void HoverPreviewProxyModel::setFilter(QString filter, enum FilterMode mode) m_filter = filter; m_filterMode = mode; +#if QT_VERSION >= QT_VERSION_CHECK(6, 12, 0) + beginFilterChange(); + endFilterChange(); +#else invalidateFilter(); +#endif } void HoverPreviewProxyModel::clearFilter() diff --git a/panels/dock/tray/ksortfilterproxymodel.cpp b/panels/dock/tray/ksortfilterproxymodel.cpp index d8fb471a7..3c83c660a 100644 --- a/panels/dock/tray/ksortfilterproxymodel.cpp +++ b/panels/dock/tray/ksortfilterproxymodel.cpp @@ -246,7 +246,12 @@ void KSortFilterProxyModel::componentComplete() void KSortFilterProxyModel::invalidateFilter() { +#if QT_VERSION >= QT_VERSION_CHECK(6, 12, 0) + beginFilterChange(); + endFilterChange(); +#else QSortFilterProxyModel::invalidateFilter(); +#endif } #include "moc_ksortfilterproxymodel.cpp"