diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-11-10 13:18:30 +0100 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2021-12-21 11:21:25 +0100 |
commit | dff579147b07cd15888a47c303e36684e9930f9f (patch) | |
tree | 995c5d29f84e3eb8da9231d865985593464f727c /src/client/qwaylandwindow.cpp | |
parent | 719a55be13bdadfa659a732755f280e276a894bd (diff) | |
download | qtwayland-dff579147b07cd15888a47c303e36684e9930f9f.tar.gz |
client: Fix crash on shutdown on Mesa driver
On Wayland, then the mesa driver is in use, calling
eglDestroySurface() while OpenGL commands are being
executed may crash. While this means the driver does
not operate by the specs in this case, the driver is
so popular that it makes sense to work around it.
To work around this, we read-lock the surface while
rendering and wait for a write-lock before we destroy
the EGL surface.
[ChangeLog][QtWaylandClient] Fixed a crash on shutdown that could
happen with some graphics-heavy applications when running on Mesa
drivers.
Pick-to: 6.3
Fixes: QTBUG-92249
Change-Id: I8b8461066cc9f948dc44ddeeddaa6e7d92b76f04
Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/client/qwaylandwindow.cpp')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index 3481a8fa..0b4347a8 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -77,6 +77,7 @@ QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display) : QPlatformWindow(window) , mDisplay(display) , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) + , mSurfaceLock(QReadWriteLock::Recursive) { { bool ok; @@ -235,6 +236,16 @@ bool QWaylandWindow::shouldCreateSubSurface() const return QPlatformWindow::parent() != nullptr; } +void QWaylandWindow::beginFrame() +{ + mSurfaceLock.lockForRead(); +} + +void QWaylandWindow::endFrame() +{ + mSurfaceLock.unlock(); +} + void QWaylandWindow::reset() { delete mShellSurface; @@ -242,10 +253,10 @@ void QWaylandWindow::reset() delete mSubSurfaceWindow; mSubSurfaceWindow = nullptr; - invalidateSurface(); if (mSurface) { emit wlSurfaceDestroyed(); QWriteLocker lock(&mSurfaceLock); + invalidateSurface(); mSurface.reset(); } |