From f7636a54a11a0c3d246a826e776fa115d69b7bbd Mon Sep 17 00:00:00 2001 From: Ivy233 Date: Sat, 14 Feb 2026 11:12:15 +0800 Subject: [PATCH] fix(notification): avoid delayed-remove id collision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- panels/notification/bubble/bubblemodel.cpp | 4 ++-- panels/notification/bubble/bubblemodel.h | 4 ++-- panels/notification/bubble/package/Bubble.qml | 4 ++-- panels/notification/common/memoryaccessor.cpp | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/panels/notification/bubble/bubblemodel.cpp b/panels/notification/bubble/bubblemodel.cpp index 84cf93361..8960a64c0 100644 --- a/panels/notification/bubble/bubblemodel.cpp +++ b/panels/notification/bubble/bubblemodel.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -83,7 +83,7 @@ void BubbleModel::clear() m_bubbles.clear(); endResetModel(); m_delayBubbles.clear(); - m_delayRemovedBubble = -1; + m_delayRemovedBubble = 0; updateLevel(); m_updateTimeTipTimer->stop(); diff --git a/panels/notification/bubble/bubblemodel.h b/panels/notification/bubble/bubblemodel.h index 1398f4925..00f31b1d3 100644 --- a/panels/notification/bubble/bubblemodel.h +++ b/panels/notification/bubble/bubblemodel.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -82,7 +82,7 @@ class BubbleModel : public QAbstractListModel int m_contentRowCount{6}; const int OverlayMaxCount{2}; QList m_delayBubbles; - qint64 m_delayRemovedBubble{-1}; + qint64 m_delayRemovedBubble{0}; const int DelayRemovBubbleTime{1000}; }; diff --git a/panels/notification/bubble/package/Bubble.qml b/panels/notification/bubble/package/Bubble.qml index 6db090156..10f3e3875 100644 --- a/panels/notification/bubble/package/Bubble.qml +++ b/panels/notification/bubble/package/Bubble.qml @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2023 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: LGPL-3.0-or-later @@ -16,7 +16,7 @@ Control { if (control.hovered) { Applet.bubbles.delayRemovedBubble = bubble.id } else { - Applet.bubbles.delayRemovedBubble = -1 + Applet.bubbles.delayRemovedBubble = 0 } } diff --git a/panels/notification/common/memoryaccessor.cpp b/panels/notification/common/memoryaccessor.cpp index 8672b192f..0eb4c08d7 100644 --- a/panels/notification/common/memoryaccessor.cpp +++ b/panels/notification/common/memoryaccessor.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-or-later @@ -34,6 +34,7 @@ qint64 MemoryAccessor::replaceEntity(qint64 id, const NotifyEntity &entity) const auto index = (iter - m_entities.begin()); Q_ASSERT(index >= 0); m_entities[index] = entity; + m_entities[index].setId(id); } else { return -1; }