From 6173e1d6f82b3bc205c1bebdc8481c1dbff4572f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 19 Jun 2018 15:09:33 +0200 Subject: Build the Windows platform plugin with QT_NO_FOREACH ...for consistency with the other platform plugins. Change-Id: I85946d610a62c19140618c83f80c4aa63fce4bc3 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowscontext.cpp | 2 +- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 8 ++++---- src/plugins/platforms/windows/qwindowsintegration.cpp | 2 +- src/plugins/platforms/windows/qwindowsmime.cpp | 5 +++-- src/plugins/platforms/windows/qwindowsscreen.cpp | 14 +++++++++----- src/plugins/platforms/windows/qwindowswindow.cpp | 3 ++- src/plugins/platforms/windows/windows.pri | 2 +- 7 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 7a9733ba01..a1bd5d20e9 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -547,7 +547,7 @@ void QWindowsContext::unregisterWindowClasses() { const HINSTANCE appInstance = static_cast(GetModuleHandle(0)); - foreach (const QString &name, d->m_registeredWindowClassNames) { + for (const QString &name : qAsConst(d->m_registeredWindowClassNames)) { if (!UnregisterClass(reinterpret_cast(name.utf16()), appInstance) && QWindowsContext::verbose) qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name)); } diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 9738b4f7f5..40ab2a4dd2 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1026,7 +1026,7 @@ static QList filterSpecs(const QStringList &filters, Q_ASSERT(filterSeparatorRE.isValid()); // Split filter specification as 'Texts (*.txt[;] *.doc)', '*.txt[;] *.doc' // into description and filters specification as '*.txt;*.doc' - foreach (const QString &filterString, filters) { + for (const QString &filterString : filters) { const int openingParenPos = filterString.lastIndexOf(QLatin1Char('(')); const int closingParenPos = openingParenPos != -1 ? filterString.indexOf(QLatin1Char(')'), openingParenPos + 1) : -1; @@ -1321,7 +1321,7 @@ void QWindowsNativeSaveFileDialog::setNameFilters(const QStringList &f) // filter only if a default suffix is set (see docs). Set the first available // suffix unless we have a defaultSuffix. if (!hasDefaultSuffix()) { - foreach (const QString &filter, f) { + for (const QString &filter : f) { const QString suffix = suffixFromFilter(filter); if (!suffix.isEmpty()) { setDefaultSuffixSys(suffix); @@ -1780,12 +1780,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow // Create a buffer with the filter strings. int totalStringLength = 0; - QList specs = + const QList specs = filterSpecs(m_options->nameFilters(), m_options->options() & QFileDialogOptions::HideNameFilterDetails, &totalStringLength); const int size = specs.size(); wchar_t *ptr = new wchar_t[totalStringLength + 2 * size + 1]; ofn->lpstrFilter = ptr; - foreach (const FilterSpec &spec, specs) { + for (const FilterSpec &spec : specs) { ptr += spec.description.toWCharArray(ptr); *ptr++ = 0; ptr += spec.filter.toWCharArray(ptr); diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 365198ff17..93dd6deedb 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -184,7 +184,7 @@ static inline unsigned parseOptions(const QStringList ¶mList, QtWindows::ProcessDpiAwareness *dpiAwareness) { unsigned options = 0; - foreach (const QString ¶m, paramList) { + for (const QString ¶m : paramList) { if (param.startsWith(QLatin1String("fontengine="))) { if (param.endsWith(QLatin1String("freetype"))) { options |= QWindowsIntegration::FontDatabaseFreeType; diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index cb8e3dc222..0cfd79f451 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -107,7 +107,8 @@ static inline QByteArray msgConversionError(const char *func, const char *format msg += ": Unable to convert DIB image. The image converter plugin for '"; msg += format; msg += "' is not available. Available formats: "; - foreach (const QByteArray &af, QImageReader::supportedImageFormats()) { + const QList &formats = QImageReader::supportedImageFormats(); + for (const QByteArray &af : formats) { msg += af; msg += ' '; } @@ -1598,7 +1599,7 @@ QVariant QWindowsMimeConverter::convertToMime(const QStringList &mimeTypes, QVariant::Type preferredType, QString *formatIn /* = 0 */) const { - foreach (const QString &format, mimeTypes) { + for (const QString &format : mimeTypes) { if (const QWindowsMime *converter = converterToMime(format, pDataObj)) { if (converter->canConvertToMime(format, pDataObj)) { const QVariant dataV = converter->convertToMime(format, pDataObj, preferredType); diff --git a/src/plugins/platforms/windows/qwindowsscreen.cpp b/src/plugins/platforms/windows/qwindowsscreen.cpp index f2d32bc9b4..bf7f359aac 100644 --- a/src/plugins/platforms/windows/qwindowsscreen.cpp +++ b/src/plugins/platforms/windows/qwindowsscreen.cpp @@ -274,9 +274,12 @@ QList QWindowsScreen::virtualSiblings() const { QList result; if (m_data.flags & QWindowsScreenData::VirtualDesktop) { - foreach (QWindowsScreen *screen, QWindowsContext::instance()->screenManager().screens()) + const QWindowsScreenManager::WindowsScreenList screens + = QWindowsContext::instance()->screenManager().screens(); + for (QWindowsScreen *screen : screens) { if (screen->data().flags & QWindowsScreenData::VirtualDesktop) result.push_back(screen); + } } else { result.push_back(const_cast(this)); } @@ -505,7 +508,8 @@ void QWindowsScreenManager::removeScreen(int index) // move those manually. if (screen != primaryScreen) { unsigned movedWindowCount = 0; - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + const QWindowList tlws = QGuiApplication::topLevelWindows(); + for (QWindow *w : tlws) { if (w->screen() == screen && w->handle() && w->type() != Qt::Desktop) { if (w->isVisible() && w->windowState() != Qt::WindowMinimized && (QWindowsWindow::baseWindowOf(w)->exStyle() & WS_EX_TOOLWINDOW)) { @@ -530,9 +534,9 @@ void QWindowsScreenManager::removeScreen(int index) bool QWindowsScreenManager::handleScreenChanges() { // Look for changed monitors, add new ones - WindowsScreenDataList newDataList = monitorData(); + const WindowsScreenDataList newDataList = monitorData(); const bool lockScreen = newDataList.size() == 1 && (newDataList.front().flags & QWindowsScreenData::LockScreen); - foreach (const QWindowsScreenData &newData, newDataList) { + for (const QWindowsScreenData &newData : newDataList) { const int existingIndex = indexOfMonitor(m_screens, newData.name); if (existingIndex != -1) { m_screens.at(existingIndex)->handleChanges(newData); @@ -564,7 +568,7 @@ void QWindowsScreenManager::clearScreens() const QWindowsScreen *QWindowsScreenManager::screenAtDp(const QPoint &p) const { - foreach (QWindowsScreen *scr, m_screens) { + for (QWindowsScreen *scr : m_screens) { if (scr->geometry().contains(p)) return scr; } diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index ecd814ab5d..150ab5fc04 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1886,7 +1886,8 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowStates state) fireExpose(QRegion(0, 0, w->width(), w->height())); exposeEventsSent = true; } - foreach (QWindow *child, QGuiApplication::allWindows()) { + const QWindowList allWindows = QGuiApplication::allWindows(); + for (QWindow *child : allWindows) { if (child != w && child->isVisible() && child->transientParent() == w) { QWindowsWindow *platformWindow = QWindowsWindow::windowsWindowOf(child); if (platformWindow && platformWindow->isLayered()) { diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index f4c396f7c5..e2129b7c9d 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -9,7 +9,7 @@ mingw: LIBS *= -luuid # For the dialog helpers: LIBS += -lshlwapi -lshell32 -ladvapi32 -DEFINES *= QT_NO_CAST_FROM_ASCII +DEFINES *= QT_NO_CAST_FROM_ASCII QT_NO_FOREACH SOURCES += \ $$PWD/qwindowswindow.cpp \ -- cgit v1.2.3