Repository navigation
Conversation
1. Enhanced TrashMonitor to properly handle GIO monitor initialization failures with error logging 2. Fixed potential null pointer dereference in destructor by adding null checks 3. Connected trash attribute changes to update the trash icon in AppsModel 4. Added updateTrashIcon method to toggle between empty/full trash icons based on trash item count 5. Updated SPDX copyright headers to 2023-2026 Log: Improved trash icon dynamic updates and error handling for trash monitoring Influence: 1. Test trash icon updates when adding/removing items from trash 2. Verify trash icon displays correctly when trash is empty vs full 3. Test application launchpad with trash monitor initialization failures 4. Verify no crashes when trash monitor fails to initialize 5. Test icon updates persist across model data refreshes 6. Verify trash icon state matches actual trash contents fix: 处理回收站监控初始化失败并更新回收站图标 1. 增强 TrashMonitor 对 GIO 监控初始化失败的错误处理和日志记录 2. 在析构函数中添加空指针检查,修复潜在的空指针解引用问题 3. 连接回收站属性变化事件,在 AppsModel 中动态更新回收站图标 4. 添加 updateTrashIcon 方法,根据回收站项目数量切换空/满回收站图标 5. 更新 SPDX 版权头至 2023-2026 Log: 改进了回收站图标的动态更新和回收站监控的错误处理 Influence: 1. 测试向回收站添加/删除项目时图标是否及时更新 2. 验证回收站为空和满时的图标显示是否正确 3. 测试回收站监控初始化失败情况下启动器功能 4. 验证回收站监控初始化失败时不会崩溃 5. 测试图标更新在模型数据刷新后是否保持 6. 验证回收站图标状态与实际回收站内容一致 PMS: BUG-285725
|
[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 GuideThis PR improves robustness of trash monitoring and wires trash state into the application model so the trash icon reflects actual contents, while adding basic error handling and header updates. Sequence diagram for trash state changes updating AppsModel trash iconsequenceDiagram
participant GIOFileMonitor
participant TrashMonitor
participant AppsModel
participant AppItem
GIOFileMonitor->>TrashMonitor: slot_onTrashMonitorChanged
TrashMonitor-->>AppsModel: trashAttributeChanged
AppsModel->>AppsModel: updateTrashIcon
AppsModel->>AppsModel: itemFromDesktopId(dde-trash.desktop)
AppsModel->>TrashMonitor: trashItemCount
AppsModel->>AppItem: setIconName(user-trash | user-trash-full)
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, and left some high level feedback:
- Consider defining and documenting the behavior of TrashMonitor::trashItemCount() when the underlying GIO monitor fails to initialize, and guard updateTrashIcon() accordingly so the AppsModel does not rely on a potentially unusable monitor in that failure path.
- Using qCInfo for every trash icon update may be noisy in normal operation; consider lowering this to qCDebug or gating it behind a condition if you only need it during troubleshooting.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider defining and documenting the behavior of TrashMonitor::trashItemCount() when the underlying GIO monitor fails to initialize, and guard updateTrashIcon() accordingly so the AppsModel does not rely on a potentially unusable monitor in that failure path.
- Using qCInfo for every trash icon update may be noisy in normal operation; consider lowering this to qCDebug or gating it behind a condition if you only need it during troubleshooting.
## Individual Comments
### Comment 1
<location path="src/models/appsmodel.cpp" line_range="73-77" />
<code_context>
Q_ASSERT(duplicatedItems.isEmpty());
qDebug() << rowCount();
+ connect(m_trashMonitor, &TrashMonitor::trashAttributeChanged, this, &AppsModel::updateTrashIcon);
+
m_tmUpdateCache->setInterval(1000);
</code_context>
<issue_to_address>
**suggestion (bug_risk):** Consider updating the trash icon once during initialization to reflect the current state before any changes occur.
Currently the icon is only updated when `trashAttributeChanged` is emitted, so the launchpad can start with an incorrect trash icon until something changes. Please call `updateTrashIcon()` once after the `connect` (or at the end of the constructor) so the initial UI reflects the current trash state.
```suggestion
qDebug() << rowCount();
connect(m_trashMonitor, &TrashMonitor::trashAttributeChanged, this, &AppsModel::updateTrashIcon);
updateTrashIcon();
m_tmUpdateCache->setInterval(1000);
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| qDebug() << rowCount(); | ||
|
|
||
| connect(m_trashMonitor, &TrashMonitor::trashAttributeChanged, this, &AppsModel::updateTrashIcon); | ||
|
|
||
| m_tmUpdateCache->setInterval(1000); |
There was a problem hiding this comment.
suggestion (bug_risk): Consider updating the trash icon once during initialization to reflect the current state before any changes occur.
Currently the icon is only updated when trashAttributeChanged is emitted, so the launchpad can start with an incorrect trash icon until something changes. Please call updateTrashIcon() once after the connect (or at the end of the constructor) so the initial UI reflects the current trash state.
| qDebug() << rowCount(); | |
| connect(m_trashMonitor, &TrashMonitor::trashAttributeChanged, this, &AppsModel::updateTrashIcon); | |
| m_tmUpdateCache->setInterval(1000); | |
| qDebug() << rowCount(); | |
| connect(m_trashMonitor, &TrashMonitor::trashAttributeChanged, this, &AppsModel::updateTrashIcon); | |
| updateTrashIcon(); | |
| m_tmUpdateCache->setInterval(1000); |
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // appsmodel.cpp - 增加对 m_trashMonitor 指针本身的防御性校验,提升极端场景下的鲁棒性
void AppsModel::updateTrashIcon()
{
if (!m_trashMonitor) {
qCWarning(logModels) << "TrashMonitor instance is null, skipping icon update";
return;
}
auto *trashItem = itemFromDesktopId(QStringLiteral("dde-trash.desktop"));
if (!trashItem) {
qCDebug(logModels) << "Trash item is not present in AppsModel";
return;
}
const int count = m_trashMonitor->trashItemCount();
const QString iconName = count > 0
? QStringLiteral("user-trash-full")
: QStringLiteral("user-trash");
if (trashItem->iconName() == iconName) {
return;
}
qCInfo(logModels) << "Updating trash icon to:" << iconName;
trashItem->setIconName(iconName);
} |
Log: Improved trash icon dynamic updates and error handling for trash monitoring
Influence:
fix: 处理回收站监控初始化失败并更新回收站图标
Log: 改进了回收站图标的动态更新和回收站监控的错误处理
Influence:
PMS: BUG-285725
Summary by Sourcery
Integrate TrashMonitor with AppsModel to keep the trash application icon in sync with actual trash contents, while improving robustness and error handling around trash monitoring and updating license headers.
New Features:
Bug Fixes:
Enhancements: