git: e5444e87a3a8 - main - x11-wm/plasma6-kwin: add upstream patch to fix KWin crash

From: Max Brazhnikov <makc_at_FreeBSD.org>
Date: Wed, 05 Mar 2025 20:03:19 UTC
The branch main has been updated by makc:

URL: https://cgit.FreeBSD.org/ports/commit/?id=e5444e87a3a84909233d69f36b425226b79a38fb

commit e5444e87a3a84909233d69f36b425226b79a38fb
Author:     Max Brazhnikov <makc@FreeBSD.org>
AuthorDate: 2025-03-05 19:33:32 +0000
Commit:     Max Brazhnikov <makc@FreeBSD.org>
CommitDate: 2025-03-05 20:00:33 +0000

    x11-wm/plasma6-kwin: add upstream patch to fix KWin crash
---
 x11-wm/plasma6-kwin/Makefile              |  1 +
 x11-wm/plasma6-kwin/files/patch-bug500819 | 46 +++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+)

diff --git a/x11-wm/plasma6-kwin/Makefile b/x11-wm/plasma6-kwin/Makefile
index 3bbb41749e53..6335aa4a702d 100644
--- a/x11-wm/plasma6-kwin/Makefile
+++ b/x11-wm/plasma6-kwin/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	kwin
 DISTVERSION=	${KDE_PLASMA_VERSION}.1
+PORTREVISION=	1
 CATEGORIES=	x11-wm kde kde-plasma
 
 COMMENT=	Easy to use, but flexible, X Window Manager and Wayland Compositor
diff --git a/x11-wm/plasma6-kwin/files/patch-bug500819 b/x11-wm/plasma6-kwin/files/patch-bug500819
new file mode 100644
index 000000000000..b62045d2de18
--- /dev/null
+++ b/x11-wm/plasma6-kwin/files/patch-bug500819
@@ -0,0 +1,46 @@
+commit b97892417ec1649c780e85e403842a77a6ab87b6
+Author: Xaver Hugl <xaver.hugl@gmail.com>
+Date:   Wed Feb 26 12:58:09 2025 +0100
+
+    backends/drm: fix testing for more connectors than CRTCs
+    
+    The connectors may not actually be enabled, so the checks could sometimes result in
+    wrongly returning Error::NotEnoughCrtcs.
+    
+    BUG: 500819
+    CCBUG: 500797
+    
+    (cherry picked from commit aa11d89a90bc4eb77bfe191a2cadede4d957d2a9)
+
+diff --git a/src/backends/drm/drm_gpu.cpp b/src/backends/drm/drm_gpu.cpp
+index 9291b5296d..4599b3dc46 100644
+--- src/backends/drm/drm_gpu.cpp
++++ src/backends/drm/drm_gpu.cpp
+@@ -345,15 +345,7 @@ void DrmGpu::removeOutputs()
+ 
+ DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors, const QList<DrmCrtc *> &crtcs)
+ {
+-    if (connectors.isEmpty() || crtcs.isEmpty()) {
+-        if (m_pipelines.isEmpty()) {
+-            // nothing to do
+-            return DrmPipeline::Error::None;
+-        }
+-        if (!connectors.empty()) {
+-            // we have no crtcs left to drive the remaining connectors
+-            return DrmPipeline::Error::InvalidArguments;
+-        }
++    if (connectors.isEmpty()) {
+         return testPipelines();
+     }
+     auto connector = connectors.takeFirst();
+@@ -363,6 +355,10 @@ DrmPipeline::Error DrmGpu::checkCrtcAssignment(QList<DrmConnector *> connectors,
+         pipeline->setCrtc(nullptr);
+         return checkCrtcAssignment(connectors, crtcs);
+     }
++    if (crtcs.isEmpty()) {
++        // we have no crtc left to drive this connector
++        return DrmPipeline::Error::InvalidArguments;
++    }
+     DrmCrtc *currentCrtc = nullptr;
+     if (m_atomicModeSetting) {
+         // try the crtc that this connector is already connected to first