Use some qExchange()

This makes the code more compact and avoids any doubts regarding
accesses to the underlying container under iteration, if any.

Change-Id: I6cf8a6113f182ae5c4401cb44fce2a3904c67489
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Marc Mutz 2019-05-17 11:38:48 +02:00
parent bbf8fc2222
commit 0f80177d98
2 changed files with 3 additions and 6 deletions

View File

@ -167,13 +167,11 @@ QWaylandDisplay::~QWaylandDisplay(void)
if (mSyncCallback)
wl_callback_destroy(mSyncCallback);
qDeleteAll(mInputDevices);
mInputDevices.clear();
qDeleteAll(qExchange(mInputDevices, {}));
foreach (QWaylandScreen *screen, mScreens) {
for (QWaylandScreen *screen : qExchange(mScreens, {})) {
QWindowSystemInterface::handleScreenRemoved(screen);
}
mScreens.clear();
qDeleteAll(mWaitingScreens);
#if QT_CONFIG(wayland_datadevice)

View File

@ -149,11 +149,10 @@ void Surface::surface_commit(Resource *resource)
}
}
foreach (wl_resource *frameCallback, m_frameCallbackList) {
for (wl_resource *frameCallback : qExchange(m_frameCallbackList, {})) {
wl_callback_send_done(frameCallback, m_compositor->time());
wl_resource_destroy(frameCallback);
}
m_frameCallbackList.clear();
}
}