qt5-qtwayland/0047-Hold-surface-read-lock-throughout-QWaylandEglWindow-.patch

86 lines
3.3 KiB
Diff
Raw Normal View History

2023-01-05 16:03:30 +00:00
From 1ec6327d2e376e76a35cd36cd7d0ed9ddd4294ce Mon Sep 17 00:00:00 2001
2022-10-31 10:20:04 +00:00
From: David Edmundson <davidedmundson@kde.org>
Date: Mon, 12 Sep 2022 13:28:08 +0100
2023-01-05 16:03:30 +00:00
Subject: [PATCH 47/57] Hold surface read lock throughout
2022-10-31 10:20:04 +00:00
QWaylandEglWindow::updateSurface
QWaylandEGLWindow::updateSurface is called from both the main and render
threads. It is called on the render thread when making the surface
current, which could be after the window is hidden if there are cleanup
jobs to be done.
Whilst the getter wlSurface() holds a read lock, it's not enough as we
need the instance alive between the two calls and throughout the mesa
code.
This potentially fixes a crash seen in mesa where we crash creating a
surface for an invalid wl_surface object.
Change-Id: I497356e752ffaf3549d174f10c4c268234b02cbd
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit 50f1ccc66c68f9f4c0b08400747942109c16b2be)
---
src/client/qwaylandwindow_p.h | 6 ++++--
.../client/wayland-egl/qwaylandeglwindow.cpp | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h
index 2be87bc0..ea3d1995 100644
--- a/src/client/qwaylandwindow_p.h
+++ b/src/client/qwaylandwindow_p.h
@@ -220,7 +220,11 @@ signals:
protected:
QWaylandDisplay *mDisplay = nullptr;
+
+ // mSurface can be written by the main thread. Other threads should claim a read lock for access
+ mutable QReadWriteLock mSurfaceLock;
QScopedPointer<QWaylandSurface> mSurface;
+
QWaylandShellSurface *mShellSurface = nullptr;
QWaylandSubSurface *mSubSurfaceWindow = nullptr;
QVector<QWaylandSubSurface *> mChildren;
@@ -294,8 +298,6 @@ private:
static QWaylandWindow *mMouseGrab;
- mutable QReadWriteLock mSurfaceLock;
-
friend class QWaylandSubSurface;
};
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
index 201b583b..64140672 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -40,6 +40,7 @@
#include "qwaylandeglwindow.h"
#include <QtWaylandClient/private/qwaylandscreen_p.h>
+#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include "qwaylandglcontext.h"
#include <QtEglSupport/private/qeglconvenience_p.h>
@@ -124,6 +125,7 @@ void QWaylandEglWindow::updateSurface(bool create)
}
mOffset = QPoint();
} else {
+ QReadLocker locker(&mSurfaceLock);
if (m_waylandEglWindow) {
int current_width, current_height;
static bool disableResizeCheck = qgetenv("QT_WAYLAND_DISABLE_RESIZECHECK").toInt();
@@ -138,8 +140,8 @@ void QWaylandEglWindow::updateSurface(bool create)
m_resize = true;
}
- } else if (create && wlSurface()) {
- m_waylandEglWindow = wl_egl_window_create(wlSurface(), sizeWithMargins.width(), sizeWithMargins.height());
+ } else if (create && mSurface) {
+ m_waylandEglWindow = wl_egl_window_create(mSurface->object(), sizeWithMargins.width(), sizeWithMargins.height());
m_requestedSize = sizeWithMargins;
}
--
2023-01-05 16:03:30 +00:00
2.39.0
2022-10-31 10:20:04 +00:00