diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 8061f19b6..fda3866cb 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -93,15 +93,17 @@ void ChatList::setSelf(QSharedPointer me) { return; } setIsUpdating(true); + beginResetModel(); mModelConnection->invokeToModel([this]() { mustBeInLinphoneThread(getClassName()); - beginResetModel(); // Avoid copy to lambdas QList> *chats = new QList>(); auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); if (!currentAccount) { - setIsUpdating(false); - endResetModel(); + mModelConnection->invokeToCore([this, chats]() { + setIsUpdating(false); + endResetModel(); + }); return; } auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter)); @@ -122,8 +124,8 @@ void ChatList::setSelf(QSharedPointer me) { mList.clear(); for (auto &chat : *chats) { connectItem(chat); + mList.append(chat); } - add(*chats); endResetModel(); setIsUpdating(false); delete chats; diff --git a/Linphone/core/chat/ChatProxy.cpp b/Linphone/core/chat/ChatProxy.cpp index 3440cef29..fd30a71a6 100644 --- a/Linphone/core/chat/ChatProxy.cpp +++ b/Linphone/core/chat/ChatProxy.cpp @@ -47,8 +47,6 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) { [this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::dataChanged, this, [this] { invalidate(); }); - connect(newChatList, &ChatList::modelAboutToBeReset, this, &ChatProxy::modelAboutToBeReset); - connect(newChatList, &ChatList::modelReset, this, &ChatProxy::modelReset); } QSortFilterProxyModel::setSourceModel(newChatList); sort(0); diff --git a/Linphone/view/Control/Display/Chat/ChatListView.qml b/Linphone/view/Control/Display/Chat/ChatListView.qml index 6066b7b3a..fce6fdb32 100644 --- a/Linphone/view/Control/Display/Chat/ChatListView.qml +++ b/Linphone/view/Control/Display/Chat/ChatListView.qml @@ -83,7 +83,6 @@ ListView { mainItem.currentIndex = index } - Component.onCompleted: cacheBuffer = Math.max(contentHeight, 0) //contentHeight>0 ? contentHeight : 0// cache all items // remove binding loop onContentHeightChanged: Qt.callLater(function () { if (mainItem)