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>
This commit is contained in:
Friedemann Kleint 2018-08-29 09:26:02 +02:00
parent 101cb8e5d9
commit e646ab2ab5
5 changed files with 14 additions and 21 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -1605,7 +1605,7 @@ QStringList QWindowsFontDatabase::addApplicationFont(const QByteArray &fontData,
void QWindowsFontDatabase::removeApplicationFonts()
{
foreach (const WinApplicationFont &font, m_applicationFonts) {
for (const WinApplicationFont &font : qAsConst(m_applicationFonts)) {
if (font.handle) {
RemoveFontMemResourceEx(font.handle);
} else {