From d8c98374e46e7cb08dcbb2703d301ca82282e9e1 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Mon, 29 Apr 2019 15:03:11 +0800 Subject: [PATCH] Fix undefined behavior when all users are logged out. --- imports/Spectral/Panel/RoomListPanel.qml | 6 +++--- qml/main.qml | 4 ++-- src/controller.h | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/imports/Spectral/Panel/RoomListPanel.qml b/imports/Spectral/Panel/RoomListPanel.qml index b6f701f..5505d9a 100644 --- a/imports/Spectral/Panel/RoomListPanel.qml +++ b/imports/Spectral/Panel/RoomListPanel.qml @@ -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) } diff --git a/qml/main.qml b/qml/main.qml index 19f06ac..f5fed8a 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -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() }) } } diff --git a/src/controller.h b/src/controller.h index 1dc208a..2e73c21 100644 --- a/src/controller.h +++ b/src/controller.h @@ -60,8 +60,6 @@ class Controller : public QObject { } void setConnection(Connection* conn) { - if (!conn) - return; if (conn == m_connection) return; m_connection = conn;