summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2018-08-29 09:26:02 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2018-09-02 16:05:39 +0000
commite646ab2ab5491659f7aa028485b7502a06d4788d (patch)
tree8bb96a6e5264dbfe186e0eaeb6ffd8e8a34ff2bf /src/corelib
parent101cb8e5d97f2f26ff0b3efd7b6e8b0e336e62be (diff)
Windows code: Fix to prefer ranged-for, as clang-tidy advises
Change-Id: Id9bb21855ae832cdbbc456326226ec72b634672e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Luca Beldi <v.ronin@yahoo.it> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qsettings_win.cpp14
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp7
-rw-r--r--src/corelib/thread/qwaitcondition_win.cpp6
-rw-r--r--src/corelib/tools/qlocale_win.cpp6
4 files changed, 13 insertions, 20 deletions
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<const wchar_t *>(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<TimerInfo> 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; i<d->timerVec.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;
}