git: 6298df5c8c1f - main - graphics/qt6-wayland: Add patch to fix crashes of Plasma-on-Wayland when right-clicking the desktop

From: Gleb Popov <arrowd_at_FreeBSD.org>
Date: Sat, 26 Jul 2025 18:23:10 UTC
The branch main has been updated by arrowd:

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

commit 6298df5c8c1fcc6db0e93613a86c579d63f6273c
Author:     Gleb Popov <arrowd@FreeBSD.org>
AuthorDate: 2025-07-25 10:38:37 +0000
Commit:     Gleb Popov <arrowd@FreeBSD.org>
CommitDate: 2025-07-26 18:22:52 +0000

    graphics/qt6-wayland: Add patch to fix crashes of Plasma-on-Wayland when right-clicking the desktop
    
    Tested by:      makc, Kenneth Raplee <kenrap@kennethraplee.com>
    Pull Request:   https://github.com/freebsd/freebsd-ports/pull/431
---
 graphics/qt6-wayland/Makefile                      |  1 +
 .../patch-src_client_qwaylandshellsurface__p.h     | 23 ++++++++++++++++++++++
 ...hellintegration_xdg-shell_qwaylandxdgshell__p.h | 13 ++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/graphics/qt6-wayland/Makefile b/graphics/qt6-wayland/Makefile
index 430aef820fe7..a63bdb800592 100644
--- a/graphics/qt6-wayland/Makefile
+++ b/graphics/qt6-wayland/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	wayland
 DISTVERSION=	${QT6_VERSION}
+PORTREVISION=	1
 CATEGORIES=	graphics wayland
 PKGNAMEPREFIX=	qt6-
 
diff --git a/graphics/qt6-wayland/files/patch-src_client_qwaylandshellsurface__p.h b/graphics/qt6-wayland/files/patch-src_client_qwaylandshellsurface__p.h
new file mode 100644
index 000000000000..9380ad7616d6
--- /dev/null
+++ b/graphics/qt6-wayland/files/patch-src_client_qwaylandshellsurface__p.h
@@ -0,0 +1,23 @@
+Add QWaylandShellSurface::nativeResource() to allow using it instead of
+surfaceRole(). The problem with latter is that it relies on RTTI, which is not
+stable across shared modules loaded with RTLD_LOCAL.
+
+x11/plasma6-layer-shell-qt calls into this private API and crashes. Linux/GCC
+users are not seeing this because libstdc++ use different algorithm for comparing
+RTTI. Our libc++ can be switched to this algorithm too by building with
+-DLIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION=2, but this is too drastic approach.
+
+Related URLs:
+* https://bugs.kde.org/show_bug.cgi?id=479679
+* https://github.com/llvm/llvm-project/issues/36746
+
+--- src/client/qwaylandshellsurface_p.h.orig	2025-05-29 00:19:49 UTC
++++ src/client/qwaylandshellsurface_p.h
+@@ -85,6 +85,7 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandShellSurface : pu
+     QPlatformWindow *platformWindow();
+     struct wl_surface *wlSurface();
+ 
++    virtual void* nativeResource(const QByteArray&) { return nullptr; }
+     virtual std::any surfaceRole() const { return std::any(); };
+ 
+     virtual void attachPopup(QWaylandShellSurface *popup) { Q_UNUSED(popup); }
diff --git a/graphics/qt6-wayland/files/patch-src_plugins_shellintegration_xdg-shell_qwaylandxdgshell__p.h b/graphics/qt6-wayland/files/patch-src_plugins_shellintegration_xdg-shell_qwaylandxdgshell__p.h
new file mode 100644
index 000000000000..205ecb55e559
--- /dev/null
+++ b/graphics/qt6-wayland/files/patch-src_plugins_shellintegration_xdg-shell_qwaylandxdgshell__p.h
@@ -0,0 +1,13 @@
+Companion change to patch-src_plugins_shellintegration_xdg-shell_qwaylandxdgshell__p.h
+
+--- src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h.orig	2025-05-29 00:19:49 UTC
++++ src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h
+@@ -75,7 +75,7 @@ class Q_WAYLANDCLIENT_EXPORT QWaylandXdgSurface : publ
+ 
+     void setSizeHints();
+ 
+-    void *nativeResource(const QByteArray &resource);
++    void *nativeResource(const QByteArray &resource) override;
+ 
+     std::any surfaceRole() const override;
+