From e468ea2d6891cc95da2a1e4fefb76a8651da4ef2 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 26 Feb 2014 13:07:42 +0100 Subject: [PATCH] Avoid re-entrency in HTTPCredidential::fetch It is likely to re-enter if there is two jobs that asks for a password. Example: 1. log out 2. restart the application 3. enter a wrong password 4. enter a wrong password again a few times 5. enter the correct password 6. it should must not prompt for the password again. Because of the re-entrency, it was still prompting for the password several times after the right password had been entered --- src/creds/httpcredentials.cpp | 10 +++++++++- src/creds/httpcredentials.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/creds/httpcredentials.cpp b/src/creds/httpcredentials.cpp index 48b2aff10a..22db507451 100644 --- a/src/creds/httpcredentials.cpp +++ b/src/creds/httpcredentials.cpp @@ -100,7 +100,8 @@ HttpCredentials::HttpCredentials() HttpCredentials::HttpCredentials(const QString& user, const QString& password) : _user(user), _password(password), - _ready(true) + _ready(true), + _fetchJobInProgress(false) { } @@ -183,6 +184,10 @@ void HttpCredentials::fetch(Account *account) return; } + if (_fetchJobInProgress) { + return; + } + fetchUser(account); QSettings *settings = account->settingsWithGroup(Theme::instance()->appName()); @@ -207,6 +212,7 @@ void HttpCredentials::fetch(Account *account) connect(job, SIGNAL(finished(QKeychain::Job*)), SLOT(slotReadJobDone(QKeychain::Job*))); job->setProperty("account", QVariant::fromValue(account)); job->start(); + _fetchJobInProgress = true; } } bool HttpCredentials::stillValid(QNetworkReply *reply) @@ -234,6 +240,7 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job) // Still, the password can be empty which indicates a problem and // the password dialog has to be opened. _ready = true; + _fetchJobInProgress = false; emit fetched(); } else { if( error != NoError ) { @@ -241,6 +248,7 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job) } bool ok; QString pwd = queryPassword(&ok); + _fetchJobInProgress = false; if (ok) { _password = pwd; _ready = true; diff --git a/src/creds/httpcredentials.h b/src/creds/httpcredentials.h index 1de04d00e6..52312834d9 100644 --- a/src/creds/httpcredentials.h +++ b/src/creds/httpcredentials.h @@ -62,6 +62,7 @@ private: QString _user; QString _password; bool _ready; + bool _fetchJobInProgress; //True if the keychain job is in progress or the input dialog visible }; } // ns Mirall