summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Redondo <qt@david-redondo.de>2024-01-22 15:33:59 +0100
committerDavid Redondo <qt@david-redondo.de>2024-01-31 10:11:58 +0100
commitfadb6d02a18aa72bc82de5fb8160e2b1ac84cf52 (patch)
tree3b1c1b61b9bff64bbea3c113f9c3f027626f82a4
parent31c5f1a09d956b61bca3d2f5066588ec3858bfd2 (diff)
client: Fix deletion of new queued shm buffers during reconnect
When reconnecting the cleanup of existing buffers is delayed in order to preserve contents and copy them to buffers belonging to the new connection. Due to the order of events it could happen that a new buffer was deleted along with the old ones but still being referenced by a window. During reconnect all QScreens are removed and new ones added for the wl_outputs on the new connection during the initial roundtrips. When the first new QScreen is added all QWindows move form the placeholder screen to it. This can cause for example QWidgets to repaint. At this point the windows are not reinited yet, and the buffer is queued inside the window. Only afterwards the reconnected signal was emitted which would cause deletion of all existing buffers including the newly queued ones. To fix this the signal is moved after the first roundtrip where all globals are announced and new buffers can be created but no new screens have been announced yet. The signal is renamed to be more fit for its new location. Change-Id: I06be14d235ac342a4b420176aadad3ccf18178fe Reviewed-by: David Edmundson <davidedmundson@kde.org> (cherry picked from commit 8e3a9b8828c4009efd47d95da12f4da7c0a80bac) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 5d5098de143bee19777660615fdcbaaf1bbc69d3) Reviewed-by: David Redondo <qt@david-redondo.de>
-rw-r--r--src/client/qwaylanddisplay.cpp4
-rw-r--r--src/client/qwaylanddisplay_p.h2
-rw-r--r--src/client/qwaylandshmbackingstore.cpp2
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp2
-rw-r--r--src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp2
5 files changed, 6 insertions, 6 deletions
diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp
index eb43313f8..afa04f5d5 100644
--- a/src/client/qwaylanddisplay.cpp
+++ b/src/client/qwaylanddisplay.cpp
@@ -389,6 +389,8 @@ bool QWaylandDisplay::initialize()
forceRoundTrip();
+ emit connected();
+
if (!mWaitingScreens.isEmpty()) {
// Give wl_output.done and zxdg_output_v1.done events a chance to arrive
forceRoundTrip();
@@ -500,8 +502,6 @@ void QWaylandDisplay::reconnect()
wl_event_queue_destroy(m_frameEventQueue);
initEventThread();
- emit reconnected();
-
auto needsRecreate = [](QPlatformWindow *window) {
return window && !static_cast<QWaylandWindow *>(window)->wlSurface();
};
diff --git a/src/client/qwaylanddisplay_p.h b/src/client/qwaylanddisplay_p.h
index 7a64749ef..89d110785 100644
--- a/src/client/qwaylanddisplay_p.h
+++ b/src/client/qwaylanddisplay_p.h
@@ -204,7 +204,7 @@ public slots:
void flushRequests();
signals:
- void reconnected();
+ void connected();
void globalAdded(const RegistryGlobal &global);
void globalRemoved(const RegistryGlobal &global);
diff --git a/src/client/qwaylandshmbackingstore.cpp b/src/client/qwaylandshmbackingstore.cpp
index 83add5945..a58ab516c 100644
--- a/src/client/qwaylandshmbackingstore.cpp
+++ b/src/client/qwaylandshmbackingstore.cpp
@@ -136,7 +136,7 @@ QWaylandShmBackingStore::QWaylandShmBackingStore(QWindow *window, QWaylandDispla
: QPlatformBackingStore(window)
, mDisplay(display)
{
- QObject::connect(mDisplay, &QWaylandDisplay::reconnected, window, [this]() {
+ QObject::connect(mDisplay, &QWaylandDisplay::connected, window, [this]() {
auto copy = mBuffers;
// clear available buffers so we create new ones
// actual deletion is deferred till after resize call so we can copy
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
index f4ed8cd61..e6258893a 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandeglwindow.cpp
@@ -24,7 +24,7 @@ QWaylandEglWindow::QWaylandEglWindow(QWindow *window, QWaylandDisplay *display)
, m_clientBufferIntegration(static_cast<QWaylandEglClientBufferIntegration *>(mDisplay->clientBufferIntegration()))
, m_format(window->requestedFormat())
{
- connect(display, &QWaylandDisplay::reconnected, this, [this] {
+ connect(display, &QWaylandDisplay::connected, this, [this] {
m_clientBufferIntegration = static_cast<QWaylandEglClientBufferIntegration *>(
mDisplay->clientBufferIntegration());
});
diff --git a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
index 685ad1e4d..472ef5fbf 100644
--- a/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
+++ b/src/hardwareintegration/client/wayland-egl/qwaylandglcontext.cpp
@@ -195,7 +195,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, QWaylandDisplay *dis
const QSurfaceFormat &fmt, QPlatformOpenGLContext *share)
: QEGLPlatformContext(fmt, share, eglDisplay), m_display(display)
{
- m_reconnectionWatcher = QObject::connect(m_display, &QWaylandDisplay::reconnected, [this]() {
+ m_reconnectionWatcher = QObject::connect(m_display, &QWaylandDisplay::connected, [this]() {
invalidateContext();
});