From fe472ee0f45c29bd7cfdde9a12631b972d28401f Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Thu, 3 Feb 2022 14:27:56 +0000 Subject: [PATCH] Client: Fix up thread usage for mSurface It didn't make sense that mSurface was protected, but the mutex was not. Also try to improve documentation. Change-Id: I2f59557cccbb2d6f0b2772ce3c8a2dab01167a6c Reviewed-by: David Edmundson --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- src/plugins/platforms/wayland/qwaylandwindow_p.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 23e7366088e..dce6590a8ec 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -76,8 +76,8 @@ QWaylandWindow *QWaylandWindow::mMouseGrab = nullptr; QWaylandWindow::QWaylandWindow(QWindow *window, QWaylandDisplay *display) : QPlatformWindow(window) , mDisplay(display) - , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) , mSurfaceLock(QReadWriteLock::Recursive) + , mResizeAfterSwap(qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) { { bool ok; diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 8fcbc4dccb6..102db1b43c1 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -253,7 +253,11 @@ protected: QMargins clientSideMargins() const; QWaylandDisplay *mDisplay = nullptr; + + // mSurface can be written by the main thread. Other threads should claim a read lock for access + mutable QReadWriteLock mSurfaceLock; QScopedPointer mSurface; + QWaylandShellSurface *mShellSurface = nullptr; QWaylandSubSurface *mSubSurfaceWindow = nullptr; QList mChildren; @@ -343,8 +347,6 @@ private: static QWaylandWindow *mMouseGrab; - mutable QReadWriteLock mSurfaceLock; - friend class QWaylandSubSurface; };