diff options
author | Paul Olav Tvete <paul.tvete@qt.io> | 2023-04-11 14:48:25 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@qt.io> | 2023-04-18 13:09:34 +0000 |
commit | 396357ca968cd0bc90b284aeb4800572ed6a72f0 (patch) | |
tree | 3572a6ef40dcb08ecea67e009c144f3ed0bcfc18 /src | |
parent | 558babd4bc3cbd1f6eb9f17f263313fd7b40069a (diff) | |
download | qtwayland-396357ca968cd0bc90b284aeb4800572ed6a72f0.tar.gz |
Make sure doApplyConfigure() is called from main thread
Task-number: QTBUG-101948
Change-Id: I867365384c43ccddf5b7a8600a3db84aa99aca6d
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/client/qwaylandwindow.cpp | 22 | ||||
-rw-r--r-- | src/client/qwaylandwindow_p.h | 3 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp index c48c9ddd..2b7f199c 100644 --- a/src/client/qwaylandwindow.cpp +++ b/src/client/qwaylandwindow.cpp @@ -30,6 +30,7 @@ #include <QtCore/QDebug> #include <QtCore/QThread> +#include <QtCore/private/qthread_p.h> #include <QtWaylandClient/private/qwayland-fractional-scale-v1.h> @@ -599,12 +600,24 @@ void QWaylandWindow::doApplyConfigure() if (!mWaitingToApplyConfigure) return; + Q_ASSERT_X(QThread::currentThreadId() == QThreadData::get2(thread())->threadId.loadRelaxed(), + "QWaylandWindow::doApplyConfigure", "not called from main thread"); + if (mShellSurface) mShellSurface->applyConfigure(); mWaitingToApplyConfigure = false; } +void QWaylandWindow::doApplyConfigureFromOtherThread() +{ + QMutexLocker lock(&mResizeLock); + if (!mCanResize || !mWaitingToApplyConfigure) + return; + doApplyConfigure(); + sendExposeEvent(QRect(QPoint(), geometry().size())); +} + void QWaylandWindow::setCanResize(bool canResize) { QMutexLocker lock(&mResizeLock); @@ -615,8 +628,13 @@ void QWaylandWindow::setCanResize(bool canResize) QWindowSystemInterface::handleGeometryChange(window(), geometry()); } if (mWaitingToApplyConfigure) { - doApplyConfigure(); - sendExposeEvent(QRect(QPoint(), geometry().size())); + bool inGuiThread = QThread::currentThreadId() == QThreadData::get2(thread())->threadId.loadRelaxed(); + if (inGuiThread) { + doApplyConfigure(); + sendExposeEvent(QRect(QPoint(), geometry().size())); + } else { + QMetaObject::invokeMethod(this, &QWaylandWindow::doApplyConfigureFromOtherThread, Qt::QueuedConnection); + } } else if (mResizeDirty) { mResizeDirty = false; sendExposeEvent(QRect(QPoint(), geometry().size())); diff --git a/src/client/qwaylandwindow_p.h b/src/client/qwaylandwindow_p.h index 636cd179..042ea566 100644 --- a/src/client/qwaylandwindow_p.h +++ b/src/client/qwaylandwindow_p.h @@ -321,6 +321,9 @@ protected: QPointer<QWaylandWindow> mTransientParent; QList<QPointer<QWaylandWindow>> mChildPopups; +private slots: + void doApplyConfigureFromOtherThread(); + private: void setGeometry_helper(const QRect &rect); void initWindow(); |