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 <lars.knoll@theqtcompany.com>
This commit is contained in:
Marc Mutz 2016-01-26 14:38:54 +01:00
parent ee2e441018
commit 40e4f75786
4 changed files with 8 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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