Repository navigation
fix: replace deprecated invalidateFilter with begin/endFilterChange on Qt 6.12 - #1799
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe 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 changessequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>f27b46e to
794d016
Compare
|
感谢仔细的评审,但这个前提在 Qt 6.12 上不成立: // qsortfilterproxymodel.h(Qt 6.12)
void endFilterChange(Directions directions = Direction::Both);实现里( 弃用注记里出现的 "Direction::Rows/Columns" 字样,是给旧的带方向参数的 另外,这个 wrapper( |
794d016 to
f71f720
Compare
…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. 验证任务栏悬停预览与托盘过滤的刷新行为保持正常
f71f720 to
91b655b
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['建议在hoverpreviewproxymodel.cpp的setFilter()方法中,将m_filter和m_filterMode的赋值移至beginFilterChange()和endFilterChange()之间,以充分利用新API避免冗余重新评估的能力'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: ['将成员变量赋值移至beginFilterChange()/endFilterChange()之间可获得新API带来的潜在性能优化'] 4. 代码安全 🔒评价: 存在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 代码审查工具自动生成 |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Summary
Qt 6.13 deprecates
QSortFilterProxyModel::invalidateFilter()in favor ofbeginFilterChange()/endFilterChange(), and the Qt 6.12 headers alreadyprovide the new API while enabling the deprecation warning. With
-Werror=deprecated-declarationsthe build fails on Qt 6.12:Changes
hoverpreviewproxymodel.cpp:25,ksortfilterproxymodel.cpp:249) with aQT_VERSIONcheck:beginFilterChange()+endFilterChange()from Qt 6.12 on,invalidateFilter()for older baselines (the new API does not exist inQt 6.8, so an unconditional switch would break the current baseline)
ksortfilterproxymodel.cppgo through theclass' own
invalidateFilter()wrapper and are fixed transitivelyTesting
gated form compiles clean with
-Werror=deprecated-declarationsSummary by Sourcery
Bug Fixes: