remove connect already in QSortFilterProxyModel (leading to crash in Windows)

This commit is contained in:
gaelle 2025-12-10 17:02:38 +01:00
parent f8a4f73993
commit 94df04c347
3 changed files with 6 additions and 7 deletions

View file

@ -93,15 +93,17 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
return; return;
} }
setIsUpdating(true); setIsUpdating(true);
beginResetModel();
mModelConnection->invokeToModel([this]() { mModelConnection->invokeToModel([this]() {
mustBeInLinphoneThread(getClassName()); mustBeInLinphoneThread(getClassName());
beginResetModel();
// Avoid copy to lambdas // Avoid copy to lambdas
QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>(); QList<QSharedPointer<ChatCore>> *chats = new QList<QSharedPointer<ChatCore>>();
auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount(); auto currentAccount = CoreModel::getInstance()->getCore()->getDefaultAccount();
if (!currentAccount) { if (!currentAccount) {
mModelConnection->invokeToCore([this, chats]() {
setIsUpdating(false); setIsUpdating(false);
endResetModel(); endResetModel();
});
return; return;
} }
auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter)); auto linphoneChatRooms = currentAccount->filterChatRooms(Utils::appStringToCoreString(mFilter));
@ -122,8 +124,8 @@ void ChatList::setSelf(QSharedPointer<ChatList> me) {
mList.clear(); mList.clear();
for (auto &chat : *chats) { for (auto &chat : *chats) {
connectItem(chat); connectItem(chat);
mList.append(chat);
} }
add(*chats);
endResetModel(); endResetModel();
setIsUpdating(false); setIsUpdating(false);
delete chats; delete chats;

View file

@ -47,8 +47,6 @@ void ChatProxy::setSourceModel(QAbstractItemModel *model) {
[this, newChatList] { emit newChatList->filterChanged(getFilterText()); }); [this, newChatList] { emit newChatList->filterChanged(getFilterText()); });
connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); }); connect(newChatList, &ChatList::chatAdded, this, [this] { invalidate(); });
connect(newChatList, &ChatList::dataChanged, 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); QSortFilterProxyModel::setSourceModel(newChatList);
sort(0); sort(0);

View file

@ -83,7 +83,6 @@ ListView {
mainItem.currentIndex = index mainItem.currentIndex = index
} }
Component.onCompleted: cacheBuffer = Math.max(contentHeight, 0) //contentHeight>0 ? contentHeight : 0// cache all items
// remove binding loop // remove binding loop
onContentHeightChanged: Qt.callLater(function () { onContentHeightChanged: Qt.callLater(function () {
if (mainItem) if (mainItem)