From e0a8fa778e3dce508695155c7d5a9a1e0bddd9f8 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 18 Jan 2022 21:36:23 +0000 Subject: [PATCH] backends/drm: fix output changes with the placeholder output As the placeholder output gets added or removed in response to other outputs getting enabled or disabled, the output list may change while iterating over them and applying changes. BUG: 448454 BUG: 448474 CCBUG: 448697 FIXED-IN: 5.24 --- src/backends/drm/drm_backend.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/backends/drm/drm_backend.cpp b/src/backends/drm/drm_backend.cpp index 96d7a4e4b8..a2fd6208d6 100644 --- a/src/backends/drm/drm_backend.cpp +++ b/src/backends/drm/drm_backend.cpp @@ -632,10 +632,14 @@ bool DrmBackend::applyOutputChanges(const WaylandOutputConfig &config) return false; } } + // first, apply changes to drm outputs. + // This may remove the placeholder output and thus change m_outputs! + for (const auto &output : qAsConst(changed)) { + output->applyQueuedChanges(config); + } + // only then apply changes to the virtual outputs for (const auto &output : qAsConst(m_outputs)) { - if (auto drmOutput = qobject_cast(output)) { - drmOutput->applyQueuedChanges(config); - } else { + if (!qobject_cast(output)) { output->applyChanges(config); } };