fix: handle removal of pending app items#715
Merged
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom Mar 2, 2026
Merged
fix: handle removal of pending app items#715deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
deepin-bot[bot] merged 1 commit intolinuxdeepin:masterfrom
Conversation
1. Add check for pending app items in watchingAppItemRemoved 2. Handle cleanup of items in m_pendingAppItems container 3. Prevent potential memory leaks from unmanaged pending items 4. Ensure early return logic to avoid processing invalid active items 5. Improve app lifecycle management during installation or initialization Influence: 1. Test removing applications while they are in a pending state 2. Verify system stability when cancelling app installations 3. Check logs for "Removing pending app item" debug messages 4. Monitor for memory leaks during repeated app install/remove cycles 5. Ensure app icons disappear correctly after pending removal PMS: BUG-347859
There was a problem hiding this comment.
Sorry @qxp930712, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
deepin pr auto review这段代码主要是在处理应用项移除时的逻辑,增加了一个针对“待处理应用项”的检查分支。以下是对这段代码的详细审查和改进建议: 1. 语法与逻辑审查
2. 代码质量
3. 代码性能
4. 代码安全
改进后的代码建议结合上述分析,建议优化查找次数,并使用更安全的指针管理方式(如果项目允许使用智能指针)。 void AppMgr::watchingAppItemRemoved(const QString &key)
{
// Check if the item is in pending container
// 使用 take() 方法,原子性地取出对象并移除键,避免两次查找
auto pendingAppItem = m_pendingAppItems.take(key);
if (pendingAppItem) {
qCDebug(logDdeIntegration) << "Removing pending app item, desktopId:" << pendingAppItem->id;
// 如果项目支持 C++11/14,建议使用 deleteLater() 确保安全删除(如果是 QObject 派生类)
// 或者使用智能指针管理,这里假设 pendingAppItem 是 QObject 派生类
pendingAppItem->deleteLater();
return;
}
// 原有逻辑
auto appItem = m_appItems.value(key);
if (!appItem) {
qCWarning(logDdeIntegration) << "App item not found for key:" << key;
// ...
}
// ...
}改进点总结:
如果 auto pendingAppItem = m_pendingAppItems.take(key);
if (pendingAppItem) {
qCDebug(logDdeIntegration) << "Removing pending app item, desktopId:" << pendingAppItem->id;
delete pendingAppItem;
return;
} |
BLumia
approved these changes
Mar 2, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, qxp930712 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 |
Member
|
/merge |
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.
Influence:
PMS: BUG-347859