Client: Emit wlSurfaceDestroyed after actually destroying wl_surface

At the moment, the QWaylandWindow::wlSurfaceDestroyed signal is emitted
before destroying the wl_surface object. It's the opposite of its name.
Furthermore, the client code in Plasma assumes that the
wlSurfaceDestroyed signal is emitted after the wl_surface is gone, but
it isn't, which is the source of bugs.

Technically, it's an API breaking change. But this ordering issue is
quite annoying to deal in the client code and the QWaylandWindow native
interface api lives in the Private namespace.

[ChangeLog][QtWaylandClient][Important Behavior Changes] The
QWaylandWindow::surfaceDestroyed() signal is emitted after actually
destroying the wl_surface object.

Change-Id: I33e27c06795653d3e20e04a36cb39be8c46797ee
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Vlad Zahorodnii 2024-01-19 13:43:08 +02:00
parent 00fc00115d
commit 9d0b3cf0d2

View File

@ -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();
}
{