Skip to content

Commit 63c6cd3

Browse files
committed
fix: correct bubble ID handling in notification system
Fixed incorrect bubble ID comparison in removeById method that was causing bubble deletion failures. The method was comparing against bubbleId() instead of id(), preventing proper bubble removal. Removed the unused getBubbleIdByStorageId method and simplified the closeBubble logic by directly using the provided ID without unnecessary entity lookups and ID conversions. The issue occurred because bubbleId and storageId were being confused in the deletion process. The removeById method was incorrectly checking bubbleId() instead of the actual item id(), making it impossible to find and remove bubbles by their correct identifier. This also eliminated the need for the complex ID mapping logic in closeBubble. Influence: 1. Test bubble deletion functionality by closing notification bubbles 2. Verify that bubbles are properly removed from the interface when closed 3. Check that no orphaned bubbles remain after deletion attempts 4. Test with multiple bubbles to ensure correct individual bubble removal 5. Verify bubble count decreases appropriately after deletions fix: 修正通知系统中气泡ID处理问题 修复了removeById方法中错误的气泡ID比较问题,该问题导致气泡删除失败。方 法之前比较的是bubbleId()而不是id(),阻止了正确的气泡移除。移除了未使用 的getBubbleIdByStorageId方法,并通过直接使用提供的ID简化了closeBubble逻 辑,无需不必要的实体查找和ID转换。 该问题的发生是因为在删除过程中混淆了bubbleId和storageId。removeById方法 错误地检查bubbleId()而不是实际的item id(),导致无法通过正确的标识符找到 和移除气泡。这也消除了closeBubble中复杂的ID映射逻辑的需求。 Influence: 1. 测试气泡删除功能,关闭通知气泡 2. 验证关闭时气泡是否正确从界面移除 3. 检查删除尝试后是否没有残留的孤立气泡 4. 使用多个气泡测试,确保正确移除单个气泡 5. 验证删除后气泡计数是否适当减少 PMS: BUG-337395
1 parent 71c0b3b commit 63c6cd3

File tree

3 files changed

+2
-22
lines changed

3 files changed

+2
-22
lines changed

panels/notification/bubble/bubblemodel.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ BubbleItem *BubbleModel::removeById(qint64 id)
135135
return nullptr;
136136
}
137137
for (const auto &item : m_bubbles) {
138-
if (item->bubbleId() == id) {
138+
if (item->id() == id) {
139139
m_delayBubbles.removeAll(id);
140140
remove(m_bubbles.indexOf(item));
141141
return item;
@@ -145,17 +145,6 @@ BubbleItem *BubbleModel::removeById(qint64 id)
145145
return nullptr;
146146
}
147147

148-
uint BubbleModel::getBubbleIdByStorageId(qint64 id) const
149-
{
150-
for (const auto &item : m_bubbles) {
151-
if (item->id() == id) {
152-
return item->bubbleId();
153-
}
154-
}
155-
156-
return 0;
157-
}
158-
159148
BubbleItem *BubbleModel::bubbleItem(int bubbleIndex) const
160149
{
161150
if (bubbleIndex < 0 || bubbleIndex >= items().count())

panels/notification/bubble/bubblemodel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class BubbleModel : public QAbstractListModel
4949
Q_INVOKABLE void remove(int index);
5050
void remove(const BubbleItem *bubble);
5151
BubbleItem *removeById(qint64 id);
52-
uint getBubbleIdByStorageId(qint64 id) const;
5352
void clear();
5453

5554
BubbleItem *bubbleItem(int bubbleIndex) const;

panels/notification/bubble/bubblepanel.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,10 @@ void BubblePanel::addBubble(qint64 id)
138138

139139
void BubblePanel::closeBubble(qint64 id)
140140
{
141-
const auto entity = m_accessor->fetchEntity(id);
142-
if (entity.isValid()) {
143-
id = entity.bubbleId();
144-
} else {
145-
qDebug(notifyLog) << "Entity not found or invalid for close bubble, using storage id lookup:" << id;
146-
id = m_bubbles->getBubbleIdByStorageId(id);
147-
}
148-
149141
if (id > 0) {
150142
m_bubbles->removeById(id);
151143
} else {
152-
qWarning(notifyLog) << "Failed to close bubble: invalid bubble id for entity id:" << id << "appName:" << entity.appName() << "cTime:" << entity.cTime();
144+
qWarning(notifyLog) << "Failed to close bubble: invalid bubble id for entity id:" << id;
153145
clearInvalidBubbles();
154146
}
155147
}

0 commit comments

Comments
 (0)