When switching rooms first set the room to nullptr to clear any objects in MessageEventModel and UserListModel

This commit is contained in:
James Graham
2024-06-30 10:15:34 +01:00
parent b3bd6ee176
commit 6a100bfbab
2 changed files with 12 additions and 2 deletions

View File

@@ -25,9 +25,15 @@ void UserListModel::setRoom(NeoChatRoom *room)
}
if (m_currentRoom) {
// HACK: Reset the model to a null room first to make sure QML dismantles
// last room's objects before the room is actually changed
beginResetModel();
m_currentRoom->disconnect(this);
m_currentRoom->connection()->disconnect(this);
m_currentRoom = nullptr;
endResetModel();
}
m_currentRoom = room;
if (m_currentRoom) {