From c0b29afc470f5d868032ff0597839e841364b200 Mon Sep 17 00:00:00 2001 From: James Graham Date: Sun, 20 Nov 2022 16:55:50 +0000 Subject: [PATCH] Fix logout Fix the account editor setting page and the controller logout function so that you can logout without crashing. --- src/controller.cpp | 7 +++++-- src/qml/Settings/AccountEditorPage.qml | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controller.cpp b/src/controller.cpp index 9e5723e38..793d06043 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -291,8 +291,11 @@ void Controller::logout(Connection *conn, bool serverSideLogout) job.start(); loop.exec(); - if (conn == activeConnection() && AccountRegistry::instance().count() > 1) { - setActiveConnection(AccountRegistry::instance().accounts()[0]); + if (AccountRegistry::instance().count() > 1) { + // Only set the connection if the the account being logged out is currently active + if (conn == activeConnection()) { + setActiveConnection(AccountRegistry::instance().accounts()[0]); + } } else { setActiveConnection(nullptr); } diff --git a/src/qml/Settings/AccountEditorPage.qml b/src/qml/Settings/AccountEditorPage.qml index f73421e14..33600e082 100644 --- a/src/qml/Settings/AccountEditorPage.qml +++ b/src/qml/Settings/AccountEditorPage.qml @@ -233,7 +233,7 @@ Kirigami.ScrollablePage { Layout.fillWidth: true text: i18n("Sign out") onClicked: { - Controller.logout(model.connection, true); + Controller.logout(root.connection, true); root.closeDialog(); if (Controller.accountCount === 1) { pageStack.layers.pop();