Fix undefined behavior when all users are logged out.

This commit is contained in:
Black Hat 2019-04-29 15:03:11 +08:00
parent 2a86fbd8b6
commit d8c98374e4
3 changed files with 5 additions and 7 deletions

View File

@ -13,8 +13,8 @@ import Spectral.Setting 0.1
import SortFilterProxyModel 0.2
Item {
property var controller: null
readonly property var user: controller.connection ? controller.connection.localUser : null
property var connection: null
readonly property var user: connection ? connection.localUser : null
property int filter: 0
property var enteredRoom: null
@ -28,7 +28,7 @@ Item {
RoomListModel {
id: roomListModel
connection: controller.connection
connection: root.connection
onNewMessage: if (!window.active && MSettings.showNotification) spectralController.postNotification(roomId, eventId, roomName, senderName, text, icon)
}

View File

@ -371,7 +371,7 @@ ApplicationWindow {
clip: true
controller: spectralController
connection: spectralController.connection
onLeaveRoom: roomForm.saveReadMarker(room)
}
@ -420,7 +420,7 @@ ApplicationWindow {
Component.onCompleted: {
spectralController.initiated.connect(function() {
if (spectralController.accountCount == 0) loginDialog.open()
if (spectralController.accountCount == 0) loginDialog.createObject(window).open()
})
}
}

View File

@ -60,8 +60,6 @@ class Controller : public QObject {
}
void setConnection(Connection* conn) {
if (!conn)
return;
if (conn == m_connection)
return;
m_connection = conn;