Skip to content

Commit

Permalink
LoginDialog: connect to login outcomes in setup()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
KitsuneRal committed Oct 4, 2021
1 parent 3219b08 commit a4ccc12
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions client/logindialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QFormLayout>();
formLayout->addRow(tr("Matrix ID"), userEdit);
formLayout->addRow(tr("Password"), passwordEdit);
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit a4ccc12

Please sign in to comment.