fix(notification): avoid delayed-remove id collision#1452
fix(notification): avoid delayed-remove id collision#1452Ivy233 wants to merge 1 commit intolinuxdeepin:masterfrom
Conversation
Use InvalidId (0) for delay sentinel and hover reset, preserve ids on memory replace, and update SPDX headers. fix(notification): 修正延迟移除哨兵冲突 延迟移除使用 InvalidId(0) 避免与负数内存 ID 冲突,替换时保持内存实体 ID 一致,并更新 SPDX 版权年份。 PMS: BUG-290767
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Ivy233 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 guide (collapsed on small PRs)Reviewer's GuideUses 0 (InvalidId) as the delayed-remove sentinel to avoid collisions with negative in-memory IDs, ensures notification entities preserve their ID on replacement, and updates SPDX copyright headers across touched files. Sequence diagram for delayed notification removal with InvalidId sentinelsequenceDiagram
actor User
participant BubbleQML
participant BubbleModel
participant MemoryAccessor
participant NotifyEntity
User->>BubbleQML: Move cursor over notification
BubbleQML->>BubbleModel: set delayRemovedBubble = bubble.id
activate BubbleModel
BubbleModel->>BubbleModel: m_delayRemovedBubble = bubble.id
BubbleModel->>MemoryAccessor: replaceEntity(id, entity)
activate MemoryAccessor
MemoryAccessor->>MemoryAccessor: find entity by id in m_entities
MemoryAccessor->>NotifyEntity: setId(id)
MemoryAccessor-->>BubbleModel: return id or -1
deactivate MemoryAccessor
BubbleModel-->>BubbleQML: state updated
deactivate BubbleModel
User->>BubbleQML: Move cursor away
BubbleQML->>BubbleModel: set delayRemovedBubble = 0
activate BubbleModel
BubbleModel->>BubbleModel: m_delayRemovedBubble = 0 (InvalidId sentinel)
BubbleModel-->>BubbleQML: no delayed removal pending
deactivate BubbleModel
Updated class diagram for notification bubble model and memory accessorclassDiagram
class BubbleModel {
-int m_contentRowCount
-int OverlayMaxCount
-QList<qint64> m_delayBubbles
-qint64 m_delayRemovedBubble
-int DelayRemovBubbleTime
+void clear()
}
class MemoryAccessor {
-QVector<NotifyEntity> m_entities
+qint64 replaceEntity(qint64 id, const NotifyEntity &entity)
}
class NotifyEntity {
-qint64 m_id
+void setId(qint64 id)
}
BubbleModel --> MemoryAccessor : uses
MemoryAccessor --> NotifyEntity : stores
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 left some high level feedback:
- Consider replacing the hard-coded sentinel
0form_delayRemovedBubblein both C++ and QML with a shared named constant (e.g.,InvalidId) to avoid magic numbers and keep the sentinel value consistent across layers. - When updating
MemoryAccessor::replaceEntity, you now explicitly set the entity id toid; if other code paths also modify entities, it may be worth centralizing id assignment (e.g., via a helper or inNotifyEntity) to avoid future divergence in how ids are managed.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider replacing the hard-coded sentinel `0` for `m_delayRemovedBubble` in both C++ and QML with a shared named constant (e.g., `InvalidId`) to avoid magic numbers and keep the sentinel value consistent across layers.
- When updating `MemoryAccessor::replaceEntity`, you now explicitly set the entity id to `id`; if other code paths also modify entities, it may be worth centralizing id assignment (e.g., via a helper or in `NotifyEntity`) to avoid future divergence in how ids are managed.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review这份代码变更主要涉及通知气泡模型、内存访问器以及相关QML文件的修改。以下是对代码的详细审查意见,分为几个方面: 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
总结与改进建议
综合评分: |
Use InvalidId (0) for delay sentinel and hover reset, preserve ids on memory replace, and update SPDX headers.
fix(notification): 修正延迟移除哨兵冲突
延迟移除使用 InvalidId(0) 避免与负数内存 ID 冲突,替换时保持内存实体 ID 一致,并更新 SPDX 版权年份。
PMS: BUG-290767
PS:修复https://github.com/linuxdeepin/dde-shell/pull/1417引入的关机提示无法消除bug。
Summary by Sourcery
Fix notification bubble delayed removal behavior to avoid ID collisions and ensure consistent entity IDs.
Bug Fixes:
Enhancements: