From d17a61e6d0fbb71724fe99649fcfceb6592638ae Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Thu, 31 Jul 2025 17:25:37 +0200 Subject: [PATCH] fix double message insertion --- Linphone/core/chat/ChatCore.cpp | 14 +++++++++----- Linphone/core/chat/message/EventLogCore.hpp | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Linphone/core/chat/ChatCore.cpp b/Linphone/core/chat/ChatCore.cpp index 27e81a459..bd1b38545 100644 --- a/Linphone/core/chat/ChatCore.cpp +++ b/Linphone/core/chat/ChatCore.cpp @@ -523,11 +523,15 @@ void ChatCore::resetEventLogList(QList> list) { void ChatCore::appendEventLogsToEventLogList(QList> list) { int nbAdded = 0; for (auto &e : list) { - if (mEventLogList.contains(e)) continue; - if (auto message = e->getChatMessageCore()) - connect(message.get(), &ChatMessageCore::isReadChanged, this, [this] { emit lUpdateUnreadCount(); }); - mEventLogList.append(e); - ++nbAdded; + auto it = std::find_if(mEventLogList.begin(), mEventLogList.end(), [e](QSharedPointer event) { + return e->getEventLogId() == event->getEventLogId(); + }); + if (it == mEventLogList.end()) { + if (auto message = e->getChatMessageCore()) + connect(message.get(), &ChatMessageCore::isReadChanged, this, [this] { emit lUpdateUnreadCount(); }); + mEventLogList.append(e); + ++nbAdded; + } } if (nbAdded > 0) emit eventsInserted(list); } diff --git a/Linphone/core/chat/message/EventLogCore.hpp b/Linphone/core/chat/message/EventLogCore.hpp index bb5121389..600c71ea3 100644 --- a/Linphone/core/chat/message/EventLogCore.hpp +++ b/Linphone/core/chat/message/EventLogCore.hpp @@ -75,7 +75,7 @@ private: QSharedPointer mChatMessageCore = nullptr; QSharedPointer mCallHistoryCore = nullptr; LinphoneEnums::EventLogType mEventLogType; - bool mHandled; + bool mHandled = false; bool mImportant; bool mEphemeralRelated; QString mEventDetails;