QNetworkAccessAuthenticationManager: don't mix iterators and pointers
QList::iterator is not a pointer and shouldn't be treated as one. Convert the code to use iterators consistently (using iterators is necessary due to the call to insert()). Change-Id: I917b3ff6fdcf1f7959e35ac5b091a8140e9f833c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
a47f66cee2
commit
4ed5f826c8
@ -62,20 +62,23 @@ public:
|
||||
reserve(1);
|
||||
}
|
||||
|
||||
QNetworkAuthenticationCredential *findClosestMatch(const QString &domain)
|
||||
using QList<QNetworkAuthenticationCredential>::begin;
|
||||
using QList<QNetworkAuthenticationCredential>::end;
|
||||
|
||||
iterator findClosestMatch(const QString &domain)
|
||||
{
|
||||
iterator it = std::lower_bound(begin(), end(), domain);
|
||||
if (it == end() && !isEmpty())
|
||||
--it;
|
||||
if (it == end() || !domain.startsWith(it->domain))
|
||||
return nullptr;
|
||||
return &*it;
|
||||
return end();
|
||||
return it;
|
||||
}
|
||||
|
||||
void insert(const QString &domain, const QString &user, const QString &password)
|
||||
{
|
||||
QNetworkAuthenticationCredential *closestMatch = findClosestMatch(domain);
|
||||
if (closestMatch && closestMatch->domain == domain) {
|
||||
iterator closestMatch = findClosestMatch(domain);
|
||||
if (closestMatch != end() && closestMatch->domain == domain) {
|
||||
// we're overriding the current credentials
|
||||
closestMatch->user = user;
|
||||
closestMatch->password = password;
|
||||
@ -85,7 +88,7 @@ public:
|
||||
newCredential.user = user;
|
||||
newCredential.password = password;
|
||||
|
||||
if (closestMatch)
|
||||
if (closestMatch != end())
|
||||
QList<QNetworkAuthenticationCredential>::insert(++closestMatch, newCredential);
|
||||
else
|
||||
QList<QNetworkAuthenticationCredential>::insert(end(), newCredential);
|
||||
@ -287,9 +290,9 @@ QNetworkAccessAuthenticationManager::fetchCachedCredentials(const QUrl &url,
|
||||
|
||||
QNetworkAuthenticationCache *auth =
|
||||
static_cast<QNetworkAuthenticationCache *>(authenticationCache.requestEntryNow(cacheKey));
|
||||
QNetworkAuthenticationCredential *cred = auth->findClosestMatch(url.path());
|
||||
auto cred = auth->findClosestMatch(url.path());
|
||||
QNetworkAuthenticationCredential ret;
|
||||
if (cred)
|
||||
if (cred != auth->end())
|
||||
ret = *cred;
|
||||
authenticationCache.releaseEntry(cacheKey);
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user