From e195d429165ee3ab984bb8f6b682f2d347ead62c Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Tue, 30 Aug 2022 22:45:51 +0200 Subject: [PATCH] backends/drm: ensure pipeline mode is always in the connector mode list The current mode of an output not being in its mode list can lead to crashes --- src/backends/drm/drm_object_connector.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/backends/drm/drm_object_connector.cpp b/src/backends/drm/drm_object_connector.cpp index ffd488f874..007d0eab10 100644 --- a/src/backends/drm/drm_object_connector.cpp +++ b/src/backends/drm/drm_object_connector.cpp @@ -321,10 +321,16 @@ bool DrmConnector::updateProperties() m_modes.clear(); m_modes.append(m_driverModes); m_modes.append(generateCommonModes()); - if (!m_pipeline->mode()) { + if (m_pipeline->mode()) { + if (const auto mode = findMode(*m_pipeline->mode()->nativeMode())) { + m_pipeline->setMode(mode); + } else { + m_pipeline->setMode(m_modes.constFirst()); + } + } else { m_pipeline->setMode(m_modes.constFirst()); - m_pipeline->applyPendingChanges(); } + m_pipeline->applyPendingChanges(); if (m_pipeline->output()) { m_pipeline->output()->updateModes(); }