diff --git a/Linphone/core/chat/ChatList.cpp b/Linphone/core/chat/ChatList.cpp index 5e9ad0c04..e497492ea 100644 --- a/Linphone/core/chat/ChatList.cpp +++ b/Linphone/core/chat/ChatList.cpp @@ -25,6 +25,8 @@ #include "model/tool/ToolModel.hpp" #include +#include + #include // ============================================================================= @@ -71,12 +73,17 @@ void ChatList::connectItem(QSharedPointer chat) { }, Qt::SingleShotConnection); auto dataChange = [this, chat] { - int i = -1; - get(chat.get(), &i); - if (i != -1) { - auto modelIndex = index(i); - if (modelIndex.isValid()) emit dataChanged(modelIndex, modelIndex); - } + // Defer dataChanged to avoid destroying QML delegates synchronously + // during a SafeConnection::invokeToCore callback, which causes + // accessibility to access already-freed QQuickItem data (QTBUG). + QTimer::singleShot(0, this, [this, chat] { + int i = -1; + get(chat.get(), &i); + if (i != -1) { + auto modelIndex = index(i); + if (modelIndex.isValid()) emit dataChanged(modelIndex, modelIndex); + } + }); }; connect(chat.get(), &ChatCore::unreadMessagesCountChanged, this, [this, dataChange] { dataChange();