diff --git a/src/kpasswdserver/autotests/kpasswdservertest.cpp b/src/kpasswdserver/autotests/kpasswdservertest.cpp --- a/src/kpasswdserver/autotests/kpasswdservertest.cpp +++ b/src/kpasswdserver/autotests/kpasswdservertest.cpp @@ -533,7 +533,8 @@ protected Q_SLOTS: void checkAndFillDialog(const KIO::AuthInfo& info, const KIO::AuthInfo& filledInfo, QDialog::DialogCode code) { - Q_FOREACH(QWidget *widget, QApplication::topLevelWidgets()) { + const QList widgetsList = QApplication::topLevelWidgets(); + for (QWidget *widget : widgetsList) { if (KPasswordDialog* dialog = qobject_cast(widget)) { if (code == QDialog::Accepted) { QCOMPARE(dialog->username(), getUserNameFrom(info)); @@ -550,7 +551,8 @@ void checkRetryDialog(QDialogButtonBox::StandardButton code = s_buttonYes) { - Q_FOREACH(QWidget *widget, QApplication::topLevelWidgets()) { + const QList widgetsList = QApplication::topLevelWidgets(); + for (QWidget *widget : widgetsList) { QDialog* dialog = qobject_cast(widget); if (dialog && !dialog->inherits("KPasswordDialog")) { dialog->done(code); diff --git a/src/kpasswdserver/kpasswdserver.cpp b/src/kpasswdserver/kpasswdserver.cpp --- a/src/kpasswdserver/kpasswdserver.cpp +++ b/src/kpasswdserver/kpasswdserver.cpp @@ -201,7 +201,7 @@ bool KPasswdServer::hasPendingQuery(const QString &key, const KIO::AuthInfo &info) { const QString path2 (info.url.path().left(info.url.path().indexOf(QLatin1Char('/'))+1)); - Q_FOREACH(const Request *request, m_authPending) { + for (const Request *request : qAsConst(m_authPending)) { if (request->key != key) { continue; } @@ -473,12 +473,11 @@ { dictIterator.next(); - AuthInfoContainerList *authList = dictIterator.value(); + const AuthInfoContainerList *authList = dictIterator.value(); if (!authList) continue; - Q_FOREACH(AuthInfoContainer *current, *authList) - { + for (const AuthInfoContainer *current : *authList) { qCDebug(category) << "Evaluating: " << current->info.url.scheme() << current->info.url.host() << current->info.username; @@ -642,13 +641,13 @@ if (authList) { QString path2 = info.url.path().left(info.url.path().indexOf(QLatin1Char('/'))+1); - Q_FOREACH(AuthInfoContainer *current, *authList) - { + auto it = authList->begin(); + while (it != authList->end()) { + AuthInfoContainer *current = (*it); if (current->expire == AuthInfoContainer::expTime && - static_cast(time(nullptr)) > current->expireTime) - { - authList->removeOne(current); + static_cast(time(nullptr)) > current->expireTime) { delete current; + it = authList->erase(it); continue; } @@ -665,6 +664,8 @@ (info.username.isEmpty() || info.username == current->info.username)) return current; // TODO: Update directory info, } + + ++it; } } return nullptr; @@ -677,12 +678,13 @@ if (!authList) return; - Q_FOREACH(AuthInfoContainer *current, *authList) - { - if (current->info.realmValue == info.realmValue) - { - authList->removeOne(current); - delete current; + auto it = authList->begin(); + while (it != authList->end()) { + if ((*it)->info.realmValue == info.realmValue) { + delete (*it); + it = authList->erase(it); + } else { + ++it; } } if (authList->isEmpty()) @@ -709,13 +711,14 @@ m_authDict.insert(key, authList); } AuthInfoContainer *authItem = nullptr; - Q_FOREACH(AuthInfoContainer* current, *authList) - { - if (current->info.realmValue == info.realmValue) - { - authList->removeAll(current); - authItem = current; + auto it = authList->begin(); + while (it != authList->end()) { + if ((*it)->info.realmValue == info.realmValue) { + authItem = (*it); + it = authList->erase(it); break; + } else { + ++it; } }