From fb9f2dd87082a3f4864b8087cc1a9056ba4d541b Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Tue, 24 Feb 2026 15:00:25 +0100 Subject: [PATCH] Make the beginResetModel/mList.clear()/endResetModel sequence atomic Delete raw pointer lists after items are added to the lists --- Linphone/core/chat/files/ChatMessageFileList.cpp | 10 ++++++++-- Linphone/core/chat/message/EventLogList.cpp | 2 ++ Linphone/core/conference/ConferenceInfoList.cpp | 10 +++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Linphone/core/chat/files/ChatMessageFileList.cpp b/Linphone/core/chat/files/ChatMessageFileList.cpp index 4f7f4da79..7bf1e4630 100644 --- a/Linphone/core/chat/files/ChatMessageFileList.cpp +++ b/Linphone/core/chat/files/ChatMessageFileList.cpp @@ -51,14 +51,17 @@ void ChatMessageFileList::setSelf(QSharedPointer me) { mCoreModelConnection = SafeConnection::create(me, CoreModel::getInstance()); mCoreModelConnection->makeConnectToCore(&ChatMessageFileList::lUpdate, [this]() { mustBeInMainThread(log().arg(Q_FUNC_INFO)); - beginResetModel(); - mList.clear(); + if (!mChat) { + beginResetModel(); + mList.clear(); endResetModel(); return; } auto chatModel = mChat->getModel(); if (!chatModel) { + beginResetModel(); + mList.clear(); endResetModel(); return; } @@ -87,9 +90,12 @@ void ChatMessageFileList::setSelf(QSharedPointer me) { contents->push_back(model); } mCoreModelConnection->invokeToCore([this, contents] { + beginResetModel(); + mList.clear(); for (auto i : *contents) mList << i.template objectCast(); endResetModel(); + delete contents; }); }); }); diff --git a/Linphone/core/chat/message/EventLogList.cpp b/Linphone/core/chat/message/EventLogList.cpp index a4632cf24..183db38d2 100644 --- a/Linphone/core/chat/message/EventLogList.cpp +++ b/Linphone/core/chat/message/EventLogList.cpp @@ -178,6 +178,7 @@ void EventLogList::displayMore() { } add(*events); } + delete events; }); }); }; @@ -220,6 +221,7 @@ void EventLogList::loadMessagesUpTo(std::shared_ptr event) { connectItem(e); } add(*events); + delete events; emit messagesLoadedUpTo(event); }); } diff --git a/Linphone/core/conference/ConferenceInfoList.cpp b/Linphone/core/conference/ConferenceInfoList.cpp index 65cf2daf9..b41c15bf9 100644 --- a/Linphone/core/conference/ConferenceInfoList.cpp +++ b/Linphone/core/conference/ConferenceInfoList.cpp @@ -71,12 +71,11 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { setIsUpdating(true); mCoreModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(getClassName()); - beginResetModel(); - mList.clear(); - QList> *items = new QList>(); auto defaultAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); setAccountConnected(defaultAccount && defaultAccount->getState() == linphone::RegistrationState::Ok); if (!defaultAccount || !mAccountConnected) { + beginResetModel(); + mList.clear(); endResetModel(); setIsUpdating(false); return; @@ -84,10 +83,13 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { std::list> conferenceInfos = defaultAccount->getConferenceInformationList(); if (conferenceInfos.empty()) { + beginResetModel(); + mList.clear(); endResetModel(); setIsUpdating(false); return; } + QList> *items = new QList>(); items->push_back(nullptr); // Add Dummy conference for today for (auto conferenceInfo : conferenceInfos) { // if (conferenceInfo->getState() == linphone::ConferenceInfo::State::Cancelled) { @@ -102,6 +104,8 @@ void ConferenceInfoList::setSelf(QSharedPointer me) { } mCoreModelConnection->invokeToCore([this, items]() { mustBeInMainThread(getClassName()); + beginResetModel(); + mList.clear(); for (auto &item : *items) { connectItem(item); mList << item.template objectCast();