diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2020-01-09 10:28:57 +0100 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2020-01-09 13:08:58 +0100 |
commit | 5ed697cda35fe300d2cb828370aaee489a0f9317 (patch) | |
tree | 26a79c37bde176aa68bddea24666703fa581b302 | |
parent | f7e035446355d9cb90141e508b5d33e019e14add (diff) | |
download | qtwayland-5ed697cda35fe300d2cb828370aaee489a0f9317.tar.gz |
Avoid potential double deletion
It's not safe to use qDeleteAll on lists that change when elements are
deleted.
Change-Id: I7ec5b41da9eea839d1bda88bde621cc73a27927f
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r-- | src/compositor/compositor_api/qwaylandcompositor.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/compositor/compositor_api/qwaylandcompositor.cpp b/src/compositor/compositor_api/qwaylandcompositor.cpp index 5b77a3be..e021b742 100644 --- a/src/compositor/compositor_api/qwaylandcompositor.cpp +++ b/src/compositor/compositor_api/qwaylandcompositor.cpp @@ -236,9 +236,12 @@ void QWaylandCompositorPrivate::init() QWaylandCompositorPrivate::~QWaylandCompositorPrivate() { - qDeleteAll(clients); + // Take copies, since the lists will get modified as elements are deleted + const auto clientsToDelete = clients; + qDeleteAll(clientsToDelete); - qDeleteAll(outputs); + const auto outputsToDelete = outputs; + qDeleteAll(outputsToDelete); #if QT_CONFIG(wayland_datadevice) delete data_device_manager; |