diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index c48c9ddd00c..2b7f199c05f 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -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/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index 636cd179690..042ea56603b 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -321,6 +321,9 @@ protected: QPointer mTransientParent; QList> mChildPopups; +private slots: + void doApplyConfigureFromOtherThread(); + private: void setGeometry_helper(const QRect &rect); void initWindow();