From 40e4f75786228041c0bb9ab21268589d6dc75985 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 26 Jan 2016 14:38:54 +0100 Subject: xcb: eradicate Q_FOREACH loops [rvalues] ... by replacing them with C++11 range-for loops. This is the simplest of the patch series: Q_FOREACH took a copy, so we do, too. Except we don't, since we're just catching the return value that comes out of the function (RVO). We can't feed the rvalues into range-for, because they are non-const and would thus detach. Change-Id: I982851f15868e62b7a191676ddf4ba6b92c0a42d Reviewed-by: Lars Knoll --- src/plugins/platforms/xcb/qxcbconnection.cpp | 3 ++- src/plugins/platforms/xcb/qxcbcursor.cpp | 3 ++- src/plugins/platforms/xcb/qxcbscreen.cpp | 3 ++- src/plugins/platforms/xcb/qxcbwindow.cpp | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 8626606713..2e51576e3b 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -245,7 +245,8 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) xcb_randr_get_output_info_reply(xcb_connection(), outputInfoCookie, NULL)); // Find a fake screen - foreach (QPlatformScreen *scr, virtualDesktop->screens()) { + const auto scrs = virtualDesktop->screens(); + for (QPlatformScreen *scr : scrs) { QXcbScreen *xcbScreen = (QXcbScreen *)scr; if (xcbScreen->output() == XCB_NONE) { screen = xcbScreen; diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 0b539a2241..10cf15c8e2 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -624,7 +624,8 @@ void QXcbCursor::queryPointer(QXcbConnection *c, QXcbVirtualDesktop **virtualDes xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(c->xcb_connection(), cookie, &err); if (!err && reply) { if (virtualDesktop) { - foreach (QXcbVirtualDesktop *vd, c->virtualDesktops()) { + const auto virtualDesktops = c->virtualDesktops(); + for (QXcbVirtualDesktop *vd : virtualDesktops) { if (vd->root() == reply->root) { *virtualDesktop = vd; break; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 4cb1b29152..b4c772dd3b 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -76,7 +76,8 @@ QXcbVirtualDesktop::~QXcbVirtualDesktop() QXcbScreen *QXcbVirtualDesktop::screenAt(const QPoint &pos) const { - foreach (QXcbScreen *screen, connection()->screens()) { + const auto screens = connection()->screens(); + for (QXcbScreen *screen : screens) { if (screen->virtualDesktop() == this && screen->geometry().contains(pos)) return screen; } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 737ab90342..5e4aaa37d9 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -864,7 +864,8 @@ void QXcbWindow::hide() // Find the top level window at cursor position. // Don't use QGuiApplication::topLevelAt(): search only the virtual siblings of this window's screen QWindow *enterWindow = Q_NULLPTR; - foreach (QPlatformScreen *screen, xcbScreen()->virtualSiblings()) { + const auto screens = xcbScreen()->virtualSiblings(); + for (QPlatformScreen *screen : screens) { if (screen->geometry().contains(cursorPos)) { const QPoint devicePosition = QHighDpi::toNativePixels(cursorPos, screen->screen()); enterWindow = screen->topLevelAt(devicePosition); -- cgit v1.2.3