diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index bb33a747f6a..4c8d2eedc66 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -283,19 +283,21 @@ void QWaylandWindow::reset() mTopPopup = mTransientParent && (mTransientParent->window()->type() == Qt::Popup) ? mTransientParent : nullptr; if (mSurface) { + { + QWriteLocker lock(&mSurfaceLock); + invalidateSurface(); + if (mTransientParent) + mTransientParent->removeChildPopup(this); + delete mShellSurface; + mShellSurface = nullptr; + delete mSubSurfaceWindow; + mSubSurfaceWindow = nullptr; + mTransientParent = nullptr; + mSurface.reset(); + mViewport.reset(); + mFractionalScale.reset(); + } emit wlSurfaceDestroyed(); - QWriteLocker lock(&mSurfaceLock); - invalidateSurface(); - if (mTransientParent) - mTransientParent->removeChildPopup(this); - delete mShellSurface; - mShellSurface = nullptr; - delete mSubSurfaceWindow; - mSubSurfaceWindow = nullptr; - mTransientParent = nullptr; - mSurface.reset(); - mViewport.reset(); - mFractionalScale.reset(); } {