fix: prevent premature dataChanged emission causing dock state desync#1462
Merged
yixinshark merged 1 commit intolinuxdeepin:masterfrom Mar 2, 2026
Merged
fix: prevent premature dataChanged emission causing dock state desync#1462yixinshark merged 1 commit intolinuxdeepin:masterfrom
yixinshark merged 1 commit intolinuxdeepin:masterfrom
Conversation
There was a problem hiding this comment.
Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
551ba49 to
199913e
Compare
BLumia
previously approved these changes
Mar 2, 2026
199913e to
a9bdbe7
Compare
When a window is closed and its application is converted to a docked state (rather than fully removed), the `dataChanged` signal was previously emitted before the internal `m_data` index-shifting calculations were finished. This led downstream proxy models to fetch outdated mappings from `m_data`, resulting in empty window queries and incorrectly disappearing status indicators for other applications like the file manager. This commit defers the `dataChanged` emission until after all row shifts are fully processed. 修复应用窗口关闭时,任务栏其他应用指示器异常消失的问题。 之前当应用的窗口被关闭并且应用转为“未运行但驻留任务栏”的状态时, `dataChanged` 信号会在内部 `m_data` 映射表完成下标上移更新之前被提前分发。 这导致下游的代理模型在响应该信号并刷新视图状态时,拿到了错误的偏移地址,从而读到了空的窗口记录列表, 使得原本正常的(如文件管理器等)其他应用指示点异常消失。本次提交将 `dataChanged` 信号的发射推迟到 内部数据表的循环移数逻辑全部执行完毕之后,确保读写同步。 Log: fix(taskmanager): prevent premature dataChanged emission causing dock state desync Pms: BUG-350947
a9bdbe7 to
f866b6a
Compare
deepin pr auto reviewGit Diff 代码审查整体评价这段代码修改主要针对 详细分析语法逻辑
代码质量
代码性能
代码安全
改进建议
QVector<int> pendingDataChangedRows;
for (int pos : pendingDataChangedRows) {
if (pos >= 0 && pos < rowCount()) {
auto pIndex = this->index(pos, 0);
Q_EMIT dataChanged(pIndex, pIndex,
{TaskManager::ActiveRole, TaskManager::AttentionRole,
TaskManager::WindowsRole, TaskManager::MenusRole,
TaskManager::WinTitleRole});
}
}
// 合并连续的行变更
std::sort(pendingDataChangedRows.begin(), pendingDataChangedRows.end());
for (int i = 0; i < pendingDataChangedRows.size(); ) {
int startRow = pendingDataChangedRows[i];
int endRow = startRow;
while (i + 1 < pendingDataChangedRows.size() &&
pendingDataChangedRows[i + 1] == endRow + 1) {
endRow = pendingDataChangedRows[++i];
}
auto startIndex = this->index(startRow, 0);
auto endIndex = this->index(endRow, 0);
Q_EMIT dataChanged(startIndex, endIndex,
{TaskManager::ActiveRole, TaskManager::AttentionRole,
TaskManager::WindowsRole, TaskManager::MenusRole,
TaskManager::WinTitleRole});
i++;
}总结这次修改是一个很好的优化,解决了在模型数据不一致状态下触发信号的问题。通过延迟信号发射,确保了模型数据的一致性,提高了代码的健壮性。建议考虑上述改进点,进一步提高代码质量和性能。 |
BLumia
approved these changes
Mar 2, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, yixinshark 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a window is closed and its application is converted to a docked state (rather than fully removed), the
dataChangedsignal was previously emitted before the internalm_dataindex-shifting calculations were finished. This led downstream proxy models to fetch outdated mappings fromm_data, resulting in empty window queries and incorrectly disappearing status indicators for other applications like the file manager. This commit defers thedataChangedemission until after all row shifts are fully processed.修复应用窗口关闭时,任务栏其他应用指示器异常消失的问题。
之前当应用的窗口被关闭并且应用转为“未运行但驻留任务栏”的状态时,
dataChanged信号会在内部m_data映射表完成下标上移更新之前被提前分发。这导致下游的代理模型在响应该信号并刷新视图状态时,拿到了错误的偏移地址,从而读到了空的窗口记录列表, 使得原本正常的(如文件管理器等)其他应用指示点异常消失。本次提交将
dataChanged信号的发射推迟到 内部数据表的循环移数逻辑全部执行完毕之后,确保读写同步。Log: fix(taskmanager): prevent premature dataChanged emission causing dock state desync
Pms: BUG-350947