-
Notifications
You must be signed in to change notification settings - Fork 55
fix: use correct index when adding dock elements #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Fixed a bug where the wrong index variable was being used when adding new dock elements to the model. Changed from using 'first' variable to using the loop counter 'i' to ensure proper indexing and element ordering. This prevents potential issues with element positioning and ensures consistent behavior when managing dock items. fix: 修复添加dock元素时使用错误索引的问题 主要处理hover后,偶现hover某应用图标,显示了另外一个应用的预览窗口,问题在于taskmanager的model的源头数据出现问题, 导致了hover后显示为其他的图标,目前修改了这个索引后(这个索引是存在问题的),未复现,后续再偶现此问题需要继续分析。 PMS: BUG-339065
Reviewer's guide (collapsed on small PRs)Reviewer's GuideReplaced the incorrect ‘first’ index with the loop counter ‘i’ when inserting new dock elements to ensure proper ordering and prevent hover-preview bugs. Class diagram for updated DockGlobalElementModel data insertionclassDiagram
class DockGlobalElementModel {
m_data : list of tuple(desktopId, appModel, index)
DockGlobalElementModel(appsModel, dockModel)
}
DockGlobalElementModel : +beginInsertRows(parent, first, last)
DockGlobalElementModel : +endInsertRows()
DockGlobalElementModel : +m_data.append(tuple)
note for DockGlobalElementModel "Index in tuple changed from 'first' to 'i' for correct ordering"
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deepin pr auto review我来分析一下这段代码的差异:
- m_data.append(std::make_tuple(desktopId, m_activeAppModel, first));
+ m_data.append(std::make_tuple(desktopId, m_activeAppModel, i));
a) 逻辑正确性:
b) 代码质量:
c) 性能考虑:
d) 安全性:
// 1. 使用结构体替代元组提高可读性
struct DockElement {
QString desktopId;
QAbstractItemModel* appModel;
int index;
};
// 2. 在循环前预留空间
if (m_data.capacity() < m_data.size() + expectedSize) {
m_data.reserve(m_data.size() + expectedSize);
}
// 3. 添加空指针检查
if (!m_activeAppModel) {
qWarning() << "Active app model is null";
return;
}
// 4. 使用更清晰的变量名
m_data.append(DockElement{
desktopId,
m_activeAppModel,
currentIndex // 使用更有意义的变量名代替 i
});
这些修改将提高代码的可读性、安全性和可维护性。但最终是否采纳这些建议,需要根据具体的项目需求和上下文来决定。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: tsic404, 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 |
Fixed a bug where the wrong index variable was being used when adding new dock elements to the model. Changed from using 'first' variable to using the loop counter 'i' to ensure proper indexing and element ordering. This prevents potential issues with element positioning and ensures consistent behavior when managing dock items.
fix: 修复添加dock元素时使用错误索引的问题
主要处理hover后,偶现hover某应用图标,显示了另外一个应用的预览窗口,问题在于taskmanager的model的源头数据出现问题, 导致了hover后显示为其他的图标,目前修改了这个索引后(这个索引是存在问题的),未复现,后续再偶现此问题需要继续分析。
PMS: BUG-339065
Summary by Sourcery
Bug Fixes: