xcb: eradicate Q_FOREACH loops [needing qAsConst()]

... by replacing them with C++11 range-for loops.
To avoid detaches of these mutable Qt containers,
wrap the container in qAsConst().

Saves more than 2KiB in text size on optimized GCC 6.0
Linux AMD64 builds.

Change-Id: I9610e711edc01d2a1ba19fef65d6b000ffc77255
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
bb10
Marc Mutz 2016-01-26 14:38:54 +01:00
parent e91abaa48e
commit b393641888
5 changed files with 10 additions and 10 deletions

View File

@ -522,7 +522,7 @@ void QXcbConnection::initializeScreens()
++xcbScreenNumber;
} // for each xcb screen
foreach (QXcbVirtualDesktop *virtualDesktop, m_virtualDesktops)
for (QXcbVirtualDesktop *virtualDesktop : qAsConst(m_virtualDesktops))
virtualDesktop->subscribeToXFixesSelectionNotify();
if (m_virtualDesktops.isEmpty()) {
@ -537,7 +537,7 @@ void QXcbConnection::initializeScreens()
}
// Push the screens to QGuiApplication
foreach (QXcbScreen *screen, m_screens) {
for (QXcbScreen *screen : qAsConst(m_screens)) {
qCDebug(lcQpaScreen) << "adding" << screen << "(Primary:" << screen->isPrimary() << ")";
QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary());
}
@ -1236,7 +1236,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
#ifndef QT_NO_CLIPBOARD
m_clipboard->handleXFixesSelectionRequest(notify_event);
#endif
foreach (QXcbVirtualDesktop *virtualDesktop, m_virtualDesktops)
for (QXcbVirtualDesktop *virtualDesktop : qAsConst(m_virtualDesktops))
virtualDesktop->handleXFixesSelectionNotify(notify_event);
handled = true;
@ -1245,7 +1245,7 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event)
handled = true;
} else if (has_randr_extension && response_type == xrandr_first_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY) {
xcb_randr_screen_change_notify_event_t *change_event = (xcb_randr_screen_change_notify_event_t *)event;
foreach (QXcbScreen *s, m_screens) {
for (QXcbScreen *s : qAsConst(m_screens)) {
if (s->root() == change_event->root )
s->handleScreenChange(change_event);
}
@ -1736,7 +1736,7 @@ void QXcbConnection::processXcbEvents()
// Indicate with a null event that the event the callbacks are waiting for
// is not in the queue currently.
Q_FOREACH (PeekFunc f, m_peekFuncs)
for (PeekFunc f : qAsConst(m_peekFuncs))
f(this, 0);
m_peekFuncs.clear();

View File

@ -274,7 +274,7 @@ void QXcbConnection::xi2SetupDevices()
void QXcbConnection::finalizeXInput2()
{
foreach (XInput2TouchDeviceData *dev, m_touchDevices) {
for (XInput2TouchDeviceData *dev : qAsConst(m_touchDevices)) {
if (dev->xiDeviceInfo)
XIFreeDeviceInfo(dev->xiDeviceInfo);
delete dev;
@ -359,7 +359,7 @@ void QXcbConnection::xi2Select(xcb_window_t window)
scrollBitMask = XI_MotionMask;
scrollBitMask |= XI_ButtonReleaseMask;
int i=0;
Q_FOREACH (const ScrollingDevice& scrollingDevice, m_scrollingDevices) {
for (const ScrollingDevice& scrollingDevice : qAsConst(m_scrollingDevices)) {
if (tabletDevices.contains(scrollingDevice.deviceId))
continue; // All necessary events are already captured.
xiEventMask[i].deviceid = scrollingDevice.deviceId;

View File

@ -343,7 +343,7 @@ QXcbCursor::~QXcbCursor()
xcb_close_font(conn, cursorFont);
#ifndef QT_NO_CURSOR
foreach (xcb_cursor_t cursor, m_cursorHash)
for (xcb_cursor_t cursor : qAsConst(m_cursorHash))
xcb_free_cursor(conn, cursor);
#endif
}

View File

@ -1038,7 +1038,7 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
// catch only more specific shortcuts, i.e. Ctrl+Shift+= also generates Ctrl++ and +,
// but Ctrl++ is more specific than +, so we should skip the last one
bool ambiguous = false;
foreach (int shortcut, result) {
for (int shortcut : qAsConst(result)) {
if (int(shortcut & ~Qt::KeyboardModifierMask) == qtKey && (shortcut & mods) == mods) {
ambiguous = true;
break;

View File

@ -158,7 +158,7 @@ void QXcbVirtualDesktop::updateWorkArea()
QRect workArea = getWorkArea();
if (m_workArea != workArea) {
m_workArea = workArea;
foreach (QPlatformScreen *screen, m_screens)
for (QPlatformScreen *screen : qAsConst(m_screens))
((QXcbScreen *)screen)->updateAvailableGeometry();
}
}