client: Avoid creating decorations in the render thread

createDecoration is called when on the main thread from when window
flags change, implicitly from initWindow, and also every
handleWindowStatesChanged which will be called when we get the first
configure event in an xdg shell.

There is no need to create the decoration in
QWaylandGLContext::makeCurrent. Any current call to makeCurrent before
the platform window is shown will not create a decoration as there's a check for a shell surface. Any call afterwards  will have already been handled by initWindow. Similarly the SHM backend store does not need to handle decorations itself.

Fixes: QTBUG-105703
Pick-to: 6.7
Pick-to: 6.6
Change-Id: I644cece28277131cf7a65eaa234ff08c8431d544
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
David Edmundson 2024-01-10 23:00:26 +00:00
parent b19408d069
commit 7b16ee4ae7
2 changed files with 3 additions and 6 deletions

View File

@ -204,7 +204,6 @@ void QWaylandShmBackingStore::endPaint()
void QWaylandShmBackingStore::ensureSize()
{
waylandWindow()->setBackingStore(this);
waylandWindow()->createDecoration();
resize(mRequestedSize);
}

View File

@ -1041,6 +1041,8 @@ void QWaylandWindow::setWindowFlags(Qt::WindowFlags flags)
bool QWaylandWindow::createDecoration()
{
Q_ASSERT_X(QThread::currentThreadId() == QThreadData::get2(thread())->threadId.loadRelaxed(),
"QWaylandWindow::createDecoration", "not called from main thread");
if (!mDisplay->supportsWindowDecoration())
return false;
@ -1121,11 +1123,7 @@ bool QWaylandWindow::createDecoration()
// size and are not redrawn, leaving the new buffer empty. As a simple
// work-around, we trigger a full extra update whenever the client-side
// window decorations are toggled while the window is showing.
// Note: createDecoration() is sometimes called from the render thread
// of Qt Quick. This is essentially wrong and could potentially cause problems,
// but until the underlying issue has been fixed, we have to use invokeMethod()
// here to avoid asserts.
QMetaObject::invokeMethod(window(), &QWindow::requestUpdate);
window()->requestUpdate();
}
return mWindowDecoration;