From edec781e6fd8d103079e079e49f674a8b5cfdbeb Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Mon, 16 Aug 2021 10:18:07 +0200 Subject: [PATCH] Fix crash : chat room model need a reset on init() as elements are erased --- linphone-app/src/components/chat-room/ChatRoomModel.cpp | 4 ++-- linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index c5c78e119..a20bcffdf 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -739,9 +739,9 @@ void ChatRoomModel::initEntries(){ mIsInitialized = true; if(entries.size() >0){ - beginInsertRows(QModelIndex(), 0, entries.size()-1); + beginResetModel(); mEntries = entries; - endInsertRows(); + endResetModel(); } } diff --git a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp index 29d24b700..d989d9741 100644 --- a/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomProxyModel.cpp @@ -181,7 +181,10 @@ bool ChatRoomProxyModel::lessThan (const QModelIndex &left, const QModelIndex &r b = r.value(); if(!b) b = r.value(); - + if(!b) + return true; + if(!a) + return false; return a->mTimestamp < b->mTimestamp; } // -----------------------------------------------------------------------------