Repository navigation
Conversation
1. Connect to source model's modelAboutToBeReset and modelReset signals in DockItemModel to properly begin and end model resets, setting m_isUpdating flag to prevent redundant row operations during reset 2. Replace unconditional rebuildTreeSource on grouping role changes in RoleGroupModel with selective validation that checks whether grouping actually changed 3. Handle cases where grouping role is in the changed roles list but the actual grouping value remains the same, avoiding unnecessary full tree rebuilds 4. Add handling for rows that lose their grouping id (empty group), ensuring they are removed from their previous group 5. Include algorithm header for std::any_of These changes fix model consistency issues during source model resets and reduce unnecessary rebuilds when dataChanged signals fire for grouping-related roles without actual grouping changes. Influence: 1. Test dock task manager behavior when source model resets (e.g., application list changes) 2. Verify dock items update correctly when application metadata changes 3. Test grouping behavior when app grouping ids change 4. Verify rows that lose grouping ids are properly removed from groups 5. Test performance with frequent dataChanged signals on grouping roles 6. Verify no visual glitches or crashes during model resets 7. Test with applications that have empty grouping ids fix: 处理停靠项代理中的源模型重置 1. 在 DockItemModel 中连接源模型的 modelAboutToBeReset 和 modelReset 信 号,正确开始和结束模型重置,设置 m_isUpdating 标志以避免重置期间冗余的行 操作 2. 将 RoleGroupModel 中分组角色变化时的无条件 rebuildTreeSource 替换为选 择性验证,检查分组是否实际发生变化 3. 处理分组角色在变化角色列表中但实际分组值未变的情况,避免不必要的完整 树重建 4. 添加对失去分组 id(空分组)的行的处理,确保从之前的分组中移除 5. 包含 algorithm 头文件以使用 std::any_of 这些变更修复了源模型重置期间的模型一致性问题,并减少了当分组相关角色触发 dataChanged 信号但实际分组未变时的不必要重建。 Influence: 1. 测试源模型重置时停靠任务管理器的行为(例如应用程序列表变化) 2. 验证应用程序元数据变化时停靠项正确更新 3. 测试应用程序分组 id 变化时的分组行为 4. 验证失去分组 id 的行正确从分组中移除 5. 测试分组角色频繁触发 dataChanged 信号时的性能 6. 验证模型重置期间无视觉故障或崩溃 7. 测试分组 id 为空的应用程序 PMS: TASK-398199
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: wjyrich 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 |
Reviewer's GuideThe proxy models now remain consistent across source-model resets while avoiding unnecessary grouped-tree rebuilds when dataChanged notifications do not alter row membership, including correct removal of rows that lose their grouping identifier. Sequence diagram for source model reset propagationsequenceDiagram
participant SourceModel
participant DockItemModel
SourceModel->>DockItemModel: modelAboutToBeReset
DockItemModel->>DockItemModel: beginResetModel
DockItemModel->>DockItemModel: m_isUpdating = true
SourceModel->>DockItemModel: modelReset
DockItemModel->>DockItemModel: endResetModel
DockItemModel->>DockItemModel: m_isUpdating = false
Flow diagram for selective grouping validationflowchart TD
A[dataChanged] --> B{"roles.isEmpty() or roles.contains(m_roleForDeduplication)?"}
B -- No --> C[Propagate ordinary row updates]
B -- Yes --> D[Read grouping value for each affected row]
D --> E{Grouping membership changed?}
E -- No --> C
E -- Yes --> F[rebuildTreeSource]
D --> G{Grouping id is empty?}
G -- Yes --> H{Row exists in a previous group?}
H -- Yes --> F
H -- No --> C
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/taskmanager/rolegroupmodel.cpp" line_range="107" />
<code_context>
+ // Empty ids are not grouped, but a row that just lost its id
+ // must be removed from its previous group.
+ const bool changed = group.isEmpty()
+ ? std::any_of(m_rowMap.cbegin(), m_rowMap.cend(), [i](const QList<int> *rows) { return rows->contains(i); })
+ : !rows || !rows->contains(i);
+ if (changed) {
</code_context>
<issue_to_address>
**Broad updates stall the dock**
When frequent `dataChanged` signals cover many rows with empty grouping IDs in a large model, `std::any_of` scans every group and its row list for each such row, making broad updates do work proportional to empty rows times grouped rows and stalling the caller.
Use a direct row-to-group membership lookup instead of scanning every group for each ungrouped row.
</issue_to_address>| // Empty ids are not grouped, but a row that just lost its id | ||
| // must be removed from its previous group. | ||
| const bool changed = group.isEmpty() | ||
| ? std::any_of(m_rowMap.cbegin(), m_rowMap.cend(), [i](const QList<int> *rows) { return rows->contains(i); }) |
There was a problem hiding this comment.
🟡 Medium · Broad updates stall the dock
When frequent dataChanged signals cover many rows with empty grouping IDs in a large model, std::any_of scans every group and its row list for each such row, making broad updates do work proportional to empty rows times grouped rows and stalling the caller.
Use a direct row-to-group membership lookup instead of scanning every group for each ungrouped row.
Prompt for AI agents
In `panels/dock/taskmanager/rolegroupmodel.cpp` at line 107:
**Broad updates stall the dock**
When frequent `dataChanged` signals cover many rows with empty grouping IDs in a large model, `std::any_of` scans every group and its row list for each such row, making broad updates do work proportional to empty rows times grouped rows and stalling the caller.
Use a direct row-to-group membership lookup instead of scanning every group for each ungrouped row.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: ['将 std::any_of lambda 中的参数名 rows 重命名为 groupRows,避免与外层变量遮蔽'] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// rolegroupmodel.cpp - 建议将 lambda 参数 rows 重命名为 groupRows 以避免变量遮蔽
const bool changed = group.isEmpty()
? std::any_of(m_rowMap.cbegin(), m_rowMap.cend(), [i](const QList<int> *groupRows) { return groupRows->contains(i); })
: !rows || !rows->contains(i);本报告由 AI 代码审查工具自动生成 |
These changes fix model consistency issues during source model resets and reduce unnecessary rebuilds when dataChanged signals fire for grouping-related roles without actual grouping changes.
Influence:
fix: 处理停靠项代理中的源模型重置
操作
这些变更修复了源模型重置期间的模型一致性问题,并减少了当分组相关角色触发
dataChanged 信号但实际分组未变时的不必要重建。
Influence:
PMS: TASK-398199
Summary by Sourcery
Synchronize dock item resets with the source model and make grouping updates rebuild the tree only when grouping membership actually changes.
Bug Fixes:
Enhancements: