From e646ab2ab5491659f7aa028485b7502a06d4788d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 29 Aug 2018 09:26:02 +0200 Subject: Windows code: Fix to prefer ranged-for, as clang-tidy advises Change-Id: Id9bb21855ae832cdbbc456326226ec72b634672e Reviewed-by: Edward Welbourne Reviewed-by: Luca Beldi Reviewed-by: Thiago Macieira --- src/corelib/io/qsettings_win.cpp | 14 ++++++-------- src/corelib/kernel/qeventdispatcher_win.cpp | 7 ++----- src/corelib/thread/qwaitcondition_win.cpp | 6 ++---- src/corelib/tools/qlocale_win.cpp | 6 +++--- 4 files changed, 13 insertions(+), 20 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/io/qsettings_win.cpp b/src/corelib/io/qsettings_win.cpp index 751db0e015..1881d0dc7e 100644 --- a/src/corelib/io/qsettings_win.cpp +++ b/src/corelib/io/qsettings_win.cpp @@ -630,11 +630,9 @@ void QWinSettingsPrivate::remove(const QString &uKey) deleteChildGroups(handle, access); if (rKey.isEmpty()) { - QStringList childKeys = childKeysOrGroups(handle, QSettingsPrivate::ChildKeys); - - for (int i = 0; i < childKeys.size(); ++i) { - QString group = childKeys.at(i); + const QStringList childKeys = childKeysOrGroups(handle, QSettingsPrivate::ChildKeys); + for (const QString &group : childKeys) { LONG res = RegDeleteValue(handle, reinterpret_cast(group.utf16())); if (res != ERROR_SUCCESS) { qWarning("QSettings: RegDeleteValue failed on subkey \"%s\": %s", @@ -755,8 +753,8 @@ bool QWinSettingsPrivate::get(const QString &uKey, QVariant *value) const { QString rKey = escapedKey(uKey); - for (int i = 0; i < regList.size(); ++i) { - HKEY handle = regList.at(i).handle(); + for (const RegistryKey &r : regList) { + HKEY handle = r.handle(); if (handle != 0 && readKey(handle, rKey, value)) return true; @@ -772,8 +770,8 @@ QStringList QWinSettingsPrivate::children(const QString &uKey, ChildSpec spec) c NameSet result; QString rKey = escapedKey(uKey); - for (int i = 0; i < regList.size(); ++i) { - HKEY parent_handle = regList.at(i).handle(); + for (const RegistryKey &r : regList) { + HKEY parent_handle = r.handle(); if (parent_handle == 0) continue; HKEY handle = openKey(parent_handle, KEY_READ, rKey, access); diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 20fac34de7..0bddf89b15 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -894,8 +894,7 @@ QEventDispatcherWin32::registeredTimers(QObject *object) const Q_D(const QEventDispatcherWin32); QList list; - for (int i = 0; i < d->timerVec.size(); ++i) { - const WinTimerInfo *t = d->timerVec.at(i); + for (const WinTimerInfo *t : qAsConst(d->timerVec)) { if (t && t->obj == object) list << TimerInfo(t->timerId, t->interval, t->timerType); } @@ -992,9 +991,7 @@ int QEventDispatcherWin32::remainingTime(int timerId) quint64 currentTime = qt_msectime(); - WinTimerInfo *t; - for (int i=0; itimerVec.size(); i++) { - t = d->timerVec.at(i); + for (const WinTimerInfo *t : qAsConst(d->timerVec)) { if (t && t->timerId == timerId) // timer found, return time to wait return t->timeout > currentTime ? t->timeout - currentTime : 0; } diff --git a/src/corelib/thread/qwaitcondition_win.cpp b/src/corelib/thread/qwaitcondition_win.cpp index 534456a935..a6ad95b397 100644 --- a/src/corelib/thread/qwaitcondition_win.cpp +++ b/src/corelib/thread/qwaitcondition_win.cpp @@ -223,8 +223,7 @@ void QWaitCondition::wakeOne() { // wake up the first waiting thread in the queue QMutexLocker locker(&d->mtx); - for (int i = 0; i < d->queue.size(); ++i) { - QWaitConditionEvent *current = d->queue.at(i); + for (QWaitConditionEvent *current : qAsConst(d->queue)) { if (current->wokenUp) continue; SetEvent(current->event); @@ -237,8 +236,7 @@ void QWaitCondition::wakeAll() { // wake up the all threads in the queue QMutexLocker locker(&d->mtx); - for (int i = 0; i < d->queue.size(); ++i) { - QWaitConditionEvent *current = d->queue.at(i); + for (QWaitConditionEvent *current : qAsConst(d->queue)) { SetEvent(current->event); current->wokenUp = true; } diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 4f7b76a0d4..ebc4430046 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -1001,9 +1001,9 @@ LCID qt_inIsoNametoLCID(const char *name) ++c; } - for (int i = 0; i < windows_to_iso_count; ++i) { - if (!strcmp(n, windows_to_iso_list[i].iso_name)) - return windows_to_iso_list[i].windows_code; + for (const WindowsToISOListElt &i : windows_to_iso_list) { + if (!strcmp(n, i.iso_name)) + return i.windows_code; } return LOCALE_USER_DEFAULT; } -- cgit v1.2.3