Fix crash in room switching
This commit is contained in:
@@ -159,7 +159,7 @@ private:
|
|||||||
|
|
||||||
bool m_isEdit = false;
|
bool m_isEdit = false;
|
||||||
|
|
||||||
QQuickTextDocument *m_document;
|
QPointer<QQuickTextDocument> m_document;
|
||||||
|
|
||||||
QPointer<NeoChatRoom> m_room;
|
QPointer<NeoChatRoom> m_room;
|
||||||
bool completionVisible = false;
|
bool completionVisible = false;
|
||||||
|
|||||||
@@ -131,9 +131,13 @@ void RoomManager::enterRoom(NeoChatRoom *room)
|
|||||||
}
|
}
|
||||||
if (m_currentRoom && m_chatDocumentHandler) {
|
if (m_currentRoom && m_chatDocumentHandler) {
|
||||||
// We're doing these things here because it is critical that they are switched at the same time
|
// We're doing these things here because it is critical that they are switched at the same time
|
||||||
m_currentRoom->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
|
if (m_chatDocumentHandler->document()) {
|
||||||
m_chatDocumentHandler->setRoom(room);
|
m_currentRoom->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
|
||||||
m_chatDocumentHandler->document()->textDocument()->setPlainText(room->savedText());
|
m_chatDocumentHandler->setRoom(room);
|
||||||
|
m_chatDocumentHandler->document()->textDocument()->setPlainText(room->savedText());
|
||||||
|
} else {
|
||||||
|
m_chatDocumentHandler->setRoom(room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_lastCurrentRoom = std::exchange(m_currentRoom, room);
|
m_lastCurrentRoom = std::exchange(m_currentRoom, room);
|
||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
|
|||||||
@@ -234,5 +234,5 @@ private:
|
|||||||
QString m_arg;
|
QString m_arg;
|
||||||
KConfig m_config;
|
KConfig m_config;
|
||||||
KConfigGroup m_lastRoomConfig;
|
KConfigGroup m_lastRoomConfig;
|
||||||
ChatDocumentHandler *m_chatDocumentHandler;
|
QPointer<ChatDocumentHandler> m_chatDocumentHandler;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user