mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-23 13:35:58 +03:00
HttpCredentials: Do not re-enter the event loop
https://sentry.io/owncloud/desktop-win-and-mac/issues/777907931/ mention a crash in OCC::HttpCredentialsGui::showDialog One possible explaination is that this is caused by re-entring the event loop. So don't do that.
This commit is contained in:
parent
51d2e41d8b
commit
c31d3f277f
1 changed files with 19 additions and 19 deletions
|
@ -56,9 +56,7 @@ void HttpCredentialsGui::askFromUserAsync()
|
||||||
_asyncAuth->start();
|
_asyncAuth->start();
|
||||||
emit authorisationLinkChanged();
|
emit authorisationLinkChanged();
|
||||||
} else if (type == DetermineAuthTypeJob::Basic) {
|
} else if (type == DetermineAuthTypeJob::Basic) {
|
||||||
// Show the dialog
|
showDialog();
|
||||||
// We will re-enter the event loop, so better wait the next iteration
|
|
||||||
QMetaObject::invokeMethod(this, "showDialog", Qt::QueuedConnection);
|
|
||||||
} else {
|
} else {
|
||||||
// Shibboleth?
|
// Shibboleth?
|
||||||
qCWarning(lcHttpCredentialsGui) << "Bad http auth type:" << type;
|
qCWarning(lcHttpCredentialsGui) << "Bad http auth type:" << type;
|
||||||
|
@ -73,8 +71,7 @@ void HttpCredentialsGui::asyncAuthResult(OAuth::Result r, const QString &user,
|
||||||
{
|
{
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case OAuth::NotSupported:
|
case OAuth::NotSupported:
|
||||||
// We will re-enter the event loop, so better wait the next iteration
|
showDialog();
|
||||||
QMetaObject::invokeMethod(this, "showDialog", Qt::QueuedConnection);
|
|
||||||
_asyncAuth.reset(nullptr);
|
_asyncAuth.reset(nullptr);
|
||||||
return;
|
return;
|
||||||
case OAuth::Error:
|
case OAuth::Error:
|
||||||
|
@ -116,24 +113,27 @@ void HttpCredentialsGui::showDialog()
|
||||||
+ QLatin1String("<br>");
|
+ QLatin1String("<br>");
|
||||||
}
|
}
|
||||||
|
|
||||||
QInputDialog dialog;
|
QInputDialog *dialog = new QInputDialog();
|
||||||
dialog.setWindowTitle(tr("Enter Password"));
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
dialog.setLabelText(msg);
|
dialog->setWindowTitle(tr("Enter Password"));
|
||||||
dialog.setTextValue(_previousPassword);
|
dialog->setLabelText(msg);
|
||||||
dialog.setTextEchoMode(QLineEdit::Password);
|
dialog->setTextValue(_previousPassword);
|
||||||
if (auto *dialogLabel = dialog.findChild<QLabel *>()) {
|
dialog->setTextEchoMode(QLineEdit::Password);
|
||||||
|
if (auto *dialogLabel = dialog->findChild<QLabel *>()) {
|
||||||
dialogLabel->setOpenExternalLinks(true);
|
dialogLabel->setOpenExternalLinks(true);
|
||||||
dialogLabel->setTextFormat(Qt::RichText);
|
dialogLabel->setTextFormat(Qt::RichText);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ok = dialog.exec();
|
dialog->open();
|
||||||
if (ok) {
|
connect(dialog, &QDialog::finished, this, [this, dialog](int result) {
|
||||||
_password = dialog.textValue();
|
if (result == QDialog::Accepted) {
|
||||||
_refreshToken.clear();
|
_password = dialog->textValue();
|
||||||
_ready = true;
|
_refreshToken.clear();
|
||||||
persist();
|
_ready = true;
|
||||||
}
|
persist();
|
||||||
emit asked();
|
}
|
||||||
|
emit asked();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HttpCredentialsGui::requestAppPasswordText(const Account *account)
|
QString HttpCredentialsGui::requestAppPasswordText(const Account *account)
|
||||||
|
|
Loading…
Reference in a new issue