From a4ccc12162eb9b5f115a644de08e2810239b09a9 Mon Sep 17 00:00:00 2001 From: Alexey Rusakov Date: Mon, 4 Oct 2021 03:48:41 +0200 Subject: [PATCH] LoginDialog: connect to login outcomes in setup() It was done in apply() instead, that can be called several times, leading to accept() being called several times on the same dialog, breaking all kinds of assumptions and ending up in a crash. Closes #805. --- client/logindialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/logindialog.cpp b/client/logindialog.cpp index 8fd196b1c..ac5c94ab2 100644 --- a/client/logindialog.cpp +++ b/client/logindialog.cpp @@ -162,6 +162,10 @@ void LoginDialog::setup(const QString& statusMessage) serverEdit->clear(); setStatusMessage(message); }); + connect(m_connection.data(), &Connection::connected, + this, &Dialog::accept); + connect(m_connection.data(), &Connection::loginError, + this, &Dialog::applyFailed); auto* formLayout = addLayout(); formLayout->addRow(tr("Matrix ID"), userEdit); formLayout->addRow(tr("Password"), passwordEdit); @@ -194,10 +198,6 @@ void LoginDialog::apply() url.setScheme("https"); // Qt defaults to http (or even ftp for some) // Whichever the flow, the two connections are the same - connect(m_connection.data(), &Connection::connected, - this, &Dialog::accept); - connect(m_connection.data(), &Connection::loginError, - this, &Dialog::applyFailed); if (m_connection->homeserver() == url && !m_connection->loginFlows().empty()) loginWithBestFlow(); else if (!url.isValid())