community/qt6-qtwayland: backport fixes to prevent Plasma from crashing

To be released in Qt 6.7.3 but KDE requested us to ship it earlier
This commit is contained in:
Bart Ribbers 2024-08-06 16:11:33 +02:00
parent 6b860eab3c
commit 40b6961c18
3 changed files with 134 additions and 0 deletions

View File

@ -0,0 +1,43 @@
From 406995207eae8d644b6e5262aa716a48c7e471a8 Mon Sep 17 00:00:00 2001
From: David Edmundson <davidedmundson@kde.org>
Date: Wed, 10 Jul 2024 09:00:33 +0100
Subject: [PATCH] client: Guard against windows being on a null screen
calculateScreenFromSurfaceEvents uses the screen information from our
surface enter events. If this is not set yet, or refers to outputs not
yet complete we fall back to the QWindow::screen. This was introduced in
e03613524fc9f6be5c4cd7e9bdb00bc09c7f1e0b.
It was assumed that this would always be a valid value as QtBase keeps
it updated, but there are apparently paths for it to still be null.
It will be evaluated again when the surface receives a wl_enter event or
the output that we have entered is finally initialised and we will then
be marked as on the correct screen.
Change-Id: I33b4a5112c3426a8ea523d39a0658ba7ffee5298
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
(cherry picked from commit c4f91b479303dda2e49499de249018d7c66c5f99)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ec07c90cd647fd7a647f3f10dcae4d18699263df)
---
src/client/qwaylandwindow.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index c3725ffc9..192373184 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -1407,7 +1407,7 @@ void QWaylandWindow::handleScreensChanged()
{
QPlatformScreen *newScreen = calculateScreenFromSurfaceEvents();
- if (newScreen->screen() == window()->screen())
+ if (!newScreen || newScreen->screen() == window()->screen())
return;
QWindowSystemInterface::handleWindowScreenChanged(window(), newScreen->QPlatformScreen::screen());
--
GitLab

View File

@ -0,0 +1,87 @@
From 632127d7f1d86cba4dd17361f24f9fd70a0ae44c Mon Sep 17 00:00:00 2001
From: David Edmundson <davidedmundson@kde.org>
Date: Fri, 5 Jul 2024 16:13:40 +0100
Subject: [PATCH] Client: Improve thread safety determining window size on the
render thread
updateSurface is called from both the render and GUI thread. We
therefore need every property referenced to be thread safe.
Rather than guarding each property we cache the buffer size whenever the
window geometry or scale changes and put a mutex round this one
variable.
Change-Id: I4168ced27556e0e4558bbdbd1daa275d7523c33d
Reviewed-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
(cherry picked from commit 83da29c62f8fb918df8d91826d16b5d5ceb2c704)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit f817608c7152487f489d0f3a227c1d0ceb7b0c2c)
Reviewed-by: David Edmundson <davidedmundson@kde.org>
---
.../client/wayland-egl/qwaylandeglwindow.cpp | 20 +++++++++++++++----
.../client/wayland-egl/qwaylandeglwindow_p.h | 6 ++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
index 652a65630..44f1038c3 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -50,6 +50,15 @@ QWaylandWindow::WindowType QWaylandEglWindow::windowType() const
void QWaylandEglWindow::ensureSize()
{
+ // this is always called on the main thread
+ QMargins margins = mWindowDecoration ? frameMargins() : QMargins{};
+ QRect rect = geometry();
+ QSize sizeWithMargins = (rect.size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom())) * scale();
+ {
+ QWriteLocker lock(&m_bufferSizeLock);
+ m_bufferSize = sizeWithMargins;
+ }
+
updateSurface(false);
}
@@ -60,14 +69,17 @@ void QWaylandEglWindow::setGeometry(const QRect &rect)
// we're now getting a resize we don't want to create it again.
// Just resize the wl_egl_window, the EGLSurface will be created
// the next time makeCurrent is called.
- updateSurface(false);
+ ensureSize();
}
void QWaylandEglWindow::updateSurface(bool create)
{
- QMargins margins = mWindowDecoration ? frameMargins() : QMargins{};
- QRect rect = geometry();
- QSize sizeWithMargins = (rect.size() + QSize(margins.left() + margins.right(), margins.top() + margins.bottom())) * scale();
+
+ QSize sizeWithMargins;
+ {
+ QReadLocker lock(&m_bufferSizeLock);
+ sizeWithMargins = m_bufferSize;
+ }
// wl_egl_windows must have both width and height > 0
// mesa's egl returns NULL if we try to create a, invalid wl_egl_window, however not all EGL
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h
index 5b9aa9874..048f0b610 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow_p.h
@@ -60,7 +60,13 @@ private:
mutable QOpenGLFramebufferObject *m_contentFBO = nullptr;
QSurfaceFormat m_format;
+ // Size used in the last call to wl_egl_window_resize
QSize m_requestedSize;
+
+ // Size of the buffer used by QWaylandWindow
+ // This is always written to from the main thread, potentially read from the rendering thread
+ QReadWriteLock m_bufferSizeLock;
+ QSize m_bufferSize;
};
}
--
GitLab

View File

@ -34,6 +34,8 @@ esac
source="https://download.qt.io/$_rel/qt/${pkgver%.*}/${pkgver/_/-}/submodules/qtwayland-everywhere-src-${pkgver/_/-}.tar.xz source="https://download.qt.io/$_rel/qt/${pkgver%.*}/${pkgver/_/-}/submodules/qtwayland-everywhere-src-${pkgver/_/-}.tar.xz
0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch 0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch
0002-qt6-qtwayland-client-guard-against-windows-being-on-a-null-screen.patch
0003-qt6-qtwayland-Client-Improve-thread-safety-determining-window-size-on-the-render-thread.patch
" "
build() { build() {
@ -52,4 +54,6 @@ package() {
sha512sums=" sha512sums="
2cd4f45f05ae60bc7f82b94f2e9c217ee4b8322f60381e1b079b90e0687e51cfbeb10b5dd724e1cca7e422b1b101d2b91c0ee47b1a732411cef330fb052c97c2 qtwayland-everywhere-src-6.7.2.tar.xz 2cd4f45f05ae60bc7f82b94f2e9c217ee4b8322f60381e1b079b90e0687e51cfbeb10b5dd724e1cca7e422b1b101d2b91c0ee47b1a732411cef330fb052c97c2 qtwayland-everywhere-src-6.7.2.tar.xz
a278bb8c0652999b1187620a7ded28c19cffdbdd42834cbb9ab948598c59a827d22d6a59c4cfd8886702b215694d96f14e868286719f49b99031fbfc308216a0 0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch a278bb8c0652999b1187620a7ded28c19cffdbdd42834cbb9ab948598c59a827d22d6a59c4cfd8886702b215694d96f14e868286719f49b99031fbfc308216a0 0001-qt6-qtwayland-Client-Ensure-that-guessed-popup-parent-has-a-shell-surface.patch
ad8f8840ddefb932e46e4080430afa5dadb8f801d38b941bcc1af9f7a5512d249d51d5fc42346ef3c5eafd48c0f70018286ba252ec259a826d44a4bec91ceeca 0002-qt6-qtwayland-client-guard-against-windows-being-on-a-null-screen.patch
c109a7a74be3f0314a8caa82f0263f87464a3bc7e4fb00e2657e682422b1e9bad04be3e1888fc3b1a481ce5e61c3eb87a85d8803fcc69c8f4d42cfbdceba3027 0003-qt6-qtwayland-Client-Improve-thread-safety-determining-window-size-on-the-render-thread.patch
" "