When switching rooms first set the room to nullptr to clear any objects in MessageEventModel and UserListModel
This commit is contained in:
@@ -84,12 +84,16 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
beginResetModel();
|
|
||||||
if (m_currentRoom) {
|
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->disconnect(this);
|
||||||
m_reactionModels.clear();
|
m_currentRoom = nullptr;
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beginResetModel();
|
||||||
m_currentRoom = room;
|
m_currentRoom = room;
|
||||||
Q_EMIT roomChanged();
|
Q_EMIT roomChanged();
|
||||||
if (room) {
|
if (room) {
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ void UserListModel::setRoom(NeoChatRoom *room)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_currentRoom) {
|
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->disconnect(this);
|
||||||
m_currentRoom->connection()->disconnect(this);
|
m_currentRoom->connection()->disconnect(this);
|
||||||
|
m_currentRoom = nullptr;
|
||||||
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentRoom = room;
|
m_currentRoom = room;
|
||||||
|
|
||||||
if (m_currentRoom) {
|
if (m_currentRoom) {
|
||||||
|
|||||||
Reference in New Issue
Block a user