From f51f83adbc2d687cd624a6f69ed4e7d6ff506291 Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 12 Jun 2019 11:57:56 +0200 Subject: Compositor: Fix crash when destroying QWaylandSurfaces with multiple views This was a regression when we switched from foreach to range-based for. QWaylandViewPrivate::markSurfaceAsDestroyed causes QWaylandSurfacePrivate::views to mutate. Change-Id: I38881998a5480b84387062cd70ae5ec321320a24 Reviewed-by: Marc Mutz --- src/compositor/compositor_api/qwaylandsurface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/compositor/compositor_api/qwaylandsurface.cpp b/src/compositor/compositor_api/qwaylandsurface.cpp index add4020da..433b53228 100644 --- a/src/compositor/compositor_api/qwaylandsurface.cpp +++ b/src/compositor/compositor_api/qwaylandsurface.cpp @@ -151,7 +151,8 @@ void QWaylandSurfacePrivate::removeFrameCallback(QtWayland::FrameCallback *callb void QWaylandSurfacePrivate::notifyViewsAboutDestruction() { Q_Q(QWaylandSurface); - for (QWaylandView *view : qAsConst(views)) { + const auto viewsCopy = views; // Views will be removed from the list when marked as destroyed + for (QWaylandView *view : viewsCopy) { QWaylandViewPrivate::get(view)->markSurfaceAsDestroyed(q); } if (hasContent) { -- cgit v1.2.3