mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
Fix crash in chat list delegate destruction during model update (cherry pick from quanta/master c108d42d9c1292556fc79d48830ad90cf6815925)
This commit is contained in:
parent
a1b682e637
commit
5b78daf372
1 changed files with 13 additions and 6 deletions
|
|
@ -25,6 +25,8 @@
|
|||
#include "model/tool/ToolModel.hpp"
|
||||
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -71,12 +73,17 @@ void ChatList::connectItem(QSharedPointer<ChatCore> chat) {
|
|||
},
|
||||
Qt::SingleShotConnection);
|
||||
auto dataChange = [this, chat] {
|
||||
// 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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue