diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2019-05-17 11:07:02 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-05-21 10:48:37 +0200 |
commit | 5f2e1d94c07c3d4d2f0f24598f8ab385fad3b74c (patch) | |
tree | 9fbf0dadcbee835e367952aff84e41055de9f230 /src/plugins | |
parent | 7107f7501df329cf785cec1585767e5d7cbab6c2 (diff) | |
download | qtwayland-5f2e1d94c07c3d4d2f0f24598f8ab385fad3b74c.tar.gz |
Eradicate Q_FOREACH loops [1/2]: trivial cases
In this patch, we port Q_FOREACH loops to C++11 ranged-for loops. All cases are
trivial in the sense that either the argument is already const or is trivially
marked as const, either by qAsConst(), or, in the case of rvalues, by storing
to a const auto temporary first.
In addition, all loop bodies are clear enough to confirm that the container we
iterate over is not changed under iteration. This does not exclude cases where
a loop is prematurely exited just after calling a modifier on the container, as
that is safe, if not especially elegant.
Change-Id: I87a63f07797437d421567d60e52305391a3c4f21
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp | 3 | ||||
-rw-r--r-- | src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp index f396e840..ab809806 100644 --- a/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp +++ b/src/plugins/shellintegration/wl-shell/qwaylandwlshellintegration.cpp @@ -49,7 +49,8 @@ namespace QtWaylandClient { bool QWaylandWlShellIntegration::initialize(QWaylandDisplay *display) { - Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { + const auto globals = display->globals(); + for (QWaylandDisplay::RegistryGlobal global : globals) { if (global.interface == QLatin1String("wl_shell")) { m_wlShell = new QtWayland::wl_shell(display->wl_registry(), global.id, 1); break; diff --git a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp index 410f2700..4e25949f 100644 --- a/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp +++ b/src/plugins/shellintegration/xdg-shell-v5/qwaylandxdgshellv5integration.cpp @@ -51,7 +51,8 @@ namespace QtWaylandClient { bool QWaylandXdgShellV5Integration::initialize(QWaylandDisplay *display) { - Q_FOREACH (QWaylandDisplay::RegistryGlobal global, display->globals()) { + const auto globals = display->globals(); + for (QWaylandDisplay::RegistryGlobal global : globals) { if (global.interface == QLatin1String("xdg_shell")) { m_xdgShell.reset(new QWaylandXdgShellV5(display->wl_registry(), global.id)); break; |