Skip to content

Commit

Permalink
Build the Windows platform plugin with QT_NO_FOREACH
Browse files Browse the repository at this point in the history
...for consistency with the other platform plugins.

Change-Id: I85946d610a62c19140618c83f80c4aa63fce4bc3
Reviewed-by: Oliver Wolff <[email protected]>
  • Loading branch information
jobor committed Jun 22, 2018
1 parent 033a1a2 commit 6173e1d
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/plugins/platforms/windows/qwindowscontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ void QWindowsContext::unregisterWindowClasses()
{
const HINSTANCE appInstance = static_cast<HINSTANCE>(GetModuleHandle(0));

foreach (const QString &name, d->m_registeredWindowClassNames) {
for (const QString &name : qAsConst(d->m_registeredWindowClassNames)) {
if (!UnregisterClass(reinterpret_cast<LPCWSTR>(name.utf16()), appInstance) && QWindowsContext::verbose)
qErrnoWarning("UnregisterClass failed for '%s'", qPrintable(name));
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/platforms/windows/qwindowsdialoghelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ static QList<FilterSpec> 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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1780,12 +1780,12 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow

// Create a buffer with the filter strings.
int totalStringLength = 0;
QList<FilterSpec> specs =
const QList<FilterSpec> 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);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/windows/qwindowsintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ static inline unsigned parseOptions(const QStringList &paramList,
QtWindows::ProcessDpiAwareness *dpiAwareness)
{
unsigned options = 0;
foreach (const QString &param, paramList) {
for (const QString &param : paramList) {
if (param.startsWith(QLatin1String("fontengine="))) {
if (param.endsWith(QLatin1String("freetype"))) {
options |= QWindowsIntegration::FontDatabaseFreeType;
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/platforms/windows/qwindowsmime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QByteArray> &formats = QImageReader::supportedImageFormats();
for (const QByteArray &af : formats) {
msg += af;
msg += ' ';
}
Expand Down Expand Up @@ -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);
Expand Down
14 changes: 9 additions & 5 deletions src/plugins/platforms/windows/qwindowsscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,12 @@ QList<QPlatformScreen *> QWindowsScreen::virtualSiblings() const
{
QList<QPlatformScreen *> 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<QWindowsScreen *>(this));
}
Expand Down Expand Up @@ -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)) {
Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/platforms/windows/qwindowswindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/platforms/windows/windows.pri
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 6173e1d

Please sign in to comment.