Fix potential crash when opening separate rooms

This commit is contained in:
Nicolas Werner 2022-05-07 20:27:25 +02:00
parent 87070289fd
commit 9910244f6b
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -11,6 +11,7 @@
#include <QSharedPointer> #include <QSharedPointer>
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include <QString> #include <QString>
#include <QQmlEngine>
#include <set> #include <set>
#include <mtx/responses/sync.hpp> #include <mtx/responses/sync.hpp>
@ -184,7 +185,9 @@ public slots:
void resetCurrentRoom() { roomlistmodel->resetCurrentRoom(); } void resetCurrentRoom() { roomlistmodel->resetCurrentRoom(); }
TimelineModel *getRoomById(const QString &id) const TimelineModel *getRoomById(const QString &id) const
{ {
return roomlistmodel->getRoomById(id).data(); auto r = roomlistmodel->getRoomById(id).data();
QQmlEngine::setObjectOwnership(r, QQmlEngine::CppOwnership);
return r;
} }
RoomPreview getRoomPreviewById(QString roomid) const RoomPreview getRoomPreviewById(QString roomid) const
{ {