Details
-
Suggestion
-
Resolution: Done
-
P3: Somewhat important
-
4.7.2
-
None
-
qt-everywhere-opensource-src-4.7.2
SH4 architecture, embedded development
-
7dffcf8a74de16c977ddff930dd17973d2abdf9d
Description
Whenever an authentication fails once and QNetworkAccessManager::authenticationRequired is re-called it is not clear that for the authentication process to be interrupted the methods setUser/setPassword must not be called.
For example, the following code results in endless stream of signal authenticationRequired.
void AccessNetwork::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { auth->setUser(QString(username.c_str())); auth->setPassword(QString(password.c_str())); }
Also the following code will result in a loop.
void AccessNetwork::authenticationRequired(QNetworkReply *reply, QAuthenticator *auth) { if (auth->user() == QString(username.c_str()) && auth->password() == QString(password.c_str())) { auth->setUser(QString()); auth->setPassword(QString()); } else { auth->setUser(QString(username.c_str())); auth->setPassword(QString(password.c_str())); } }
That seems to happen in the code of void QAuthenticator::detach() that creates a new QAuthenticatorPrivate everytime setUser/setPassword methods are called.
I suggest that the documentation of setUser/setPassword have a warning about this behaviour.