From 94c92393b116ad05e034377e2418618527205adf Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Wed, 5 May 2021 23:00:39 +0300 Subject: [PATCH] Prevent potential QMap detaching Store resourceMap() in a local const variable to avoid detaching. --- src/wayland/xdgoutput_v1_interface.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wayland/xdgoutput_v1_interface.cpp b/src/wayland/xdgoutput_v1_interface.cpp index 32d41e0afd..34be11d6ac 100644 --- a/src/wayland/xdgoutput_v1_interface.cpp +++ b/src/wayland/xdgoutput_v1_interface.cpp @@ -121,7 +121,9 @@ void XdgOutputV1Interface::setLogicalSize(const QSize &size) } d->size = size; d->dirty = true; - for (auto resource : d->resourceMap()) { + + const auto outputResources = d->resourceMap(); + for (auto resource : outputResources) { d->send_logical_size(resource->handle, size.width(), size.height()); } } @@ -138,7 +140,9 @@ void XdgOutputV1Interface::setLogicalPosition(const QPoint &pos) } d->pos = pos; d->dirty = true; - for (auto resource : d->resourceMap()) { + + const auto outputResources = d->resourceMap(); + for (auto resource : outputResources) { d->send_logical_position(resource->handle, pos.x(), pos.y()); } } @@ -167,7 +171,9 @@ void XdgOutputV1Interface::done() return; } d->dirty = false; - for (auto resource : d->resourceMap()) { + + const auto outputResources = d->resourceMap(); + for (auto resource : outputResources) { if (wl_resource_get_version(resource->handle) < 3) { d->send_done(resource->handle); }