mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Make WebFlowCredentialsDialog cancellation- and deletion-safe
- Add new signal to let WebFlowCredentials know and emit asked() to also tell AccountState that the user won't authenticate, and triggering log-out state in the settings window. - Use deleteLater() to safely delete WebFlowCredentialsDialog, so that Qt can free it at the right time and without crashes. Do the same with it's _webView and _flow2AuthWidget on closeEvent(). Signed-off-by: Michael Schuster <michael@schuster.ms>
This commit is contained in:
parent
b6b04aeff8
commit
0bcac1882a
@ -170,6 +170,7 @@ void WebFlowCredentials::askFromUser() {
|
||||
_askDialog->show();
|
||||
|
||||
connect(_askDialog, &WebFlowCredentialsDialog::urlCatched, this, &WebFlowCredentials::slotAskFromUserCredentialsProvided);
|
||||
connect(_askDialog, &WebFlowCredentialsDialog::onClose, this, &WebFlowCredentials::slotAskFromUserCancelled);
|
||||
});
|
||||
job->start();
|
||||
|
||||
@ -205,10 +206,18 @@ void WebFlowCredentials::slotAskFromUserCredentialsProvided(const QString &user,
|
||||
emit asked();
|
||||
|
||||
_askDialog->close();
|
||||
delete _askDialog;
|
||||
_askDialog->deleteLater();
|
||||
_askDialog = nullptr;
|
||||
}
|
||||
|
||||
void WebFlowCredentials::slotAskFromUserCancelled() {
|
||||
qCDebug(lcWebFlowCredentials()) << "User cancelled reauth!";
|
||||
|
||||
emit asked();
|
||||
|
||||
_askDialog->deleteLater();
|
||||
_askDialog = nullptr;
|
||||
}
|
||||
|
||||
bool WebFlowCredentials::stillValid(QNetworkReply *reply) {
|
||||
if (reply->error() != QNetworkReply::NoError) {
|
||||
|
||||
@ -61,6 +61,7 @@ private slots:
|
||||
void slotFinished(QNetworkReply *reply);
|
||||
|
||||
void slotAskFromUserCredentialsProvided(const QString &user, const QString &pass, const QString &host);
|
||||
void slotAskFromUserCancelled();
|
||||
|
||||
void slotReadClientCertPEMJobDone(QKeychain::Job *incomingJob);
|
||||
void slotReadClientKeyPEMJobDone(QKeychain::Job *incomingJob);
|
||||
|
||||
@ -65,11 +65,16 @@ void WebFlowCredentialsDialog::closeEvent(QCloseEvent* e) {
|
||||
if (_webView) {
|
||||
// Force calling WebView::~WebView() earlier so that _profile and _page are
|
||||
// deleted in the correct order.
|
||||
delete _webView;
|
||||
_webView->deleteLater();
|
||||
_webView = nullptr;
|
||||
}
|
||||
|
||||
if (_flow2AuthWidget)
|
||||
delete _flow2AuthWidget;
|
||||
if (_flow2AuthWidget) {
|
||||
_flow2AuthWidget->deleteLater();
|
||||
_flow2AuthWidget = nullptr;
|
||||
}
|
||||
|
||||
emit onClose();
|
||||
}
|
||||
|
||||
void WebFlowCredentialsDialog::setUrl(const QUrl &url) {
|
||||
|
||||
@ -39,6 +39,7 @@ signals:
|
||||
void urlCatched(const QString user, const QString pass, const QString host);
|
||||
void styleChanged();
|
||||
void onActivate();
|
||||
void onClose();
|
||||
|
||||
private:
|
||||
void customizeStyle();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user