Fix one more ownership issue that causes crashes when switching rooms

I was hitting one more annoying crash with a backtrace inside QCache,
because we didn't set the ownership propetly for one last model. Now I
don't hit it anymore.
This commit is contained in:
Joshua Goins
2025-05-09 15:09:54 -04:00
parent 0a2af02c5f
commit b5465cd8d0

View File

@@ -53,8 +53,9 @@ MessageContentModel *ContentProvider::contentModelForEvent(NeoChatRoom *room, co
auto eventId = event->id();
const auto txnId = event->transactionId();
if (!m_eventContentModels.contains(eventId) && !m_eventContentModels.contains(txnId)) {
m_eventContentModels.insert(eventId.isEmpty() ? txnId : eventId,
new MessageContentModel(room, eventId.isEmpty() ? txnId : eventId, isReply, eventId.isEmpty()));
auto model = new MessageContentModel(room, eventId.isEmpty() ? txnId : eventId, isReply, eventId.isEmpty());
QQmlEngine::setObjectOwnership(model, QQmlEngine::CppOwnership);
m_eventContentModels.insert(eventId.isEmpty() ? txnId : eventId, model);
}
if (!eventId.isEmpty() && m_eventContentModels.contains(eventId)) {