From 48a62729166f7f07f700ada6771541afb07356e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 1 Oct 2015 14:03:48 +0200 Subject: [PATCH] [tests] Support a trasient window in the waylandclienttest Main purpose is to reproduce a crash if the parent window gets destroyed before the transient. For this the following key combo can be used: t: show transient k: close parent window q: quit application This currently causes reliably a crash in Deleted::copyToDeleted for the connect of the mainClients. --- tests/waylandclienttest.cpp | 29 +++++++++++++++++++++++++++++ tests/waylandclienttest.h | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/tests/waylandclienttest.cpp b/tests/waylandclienttest.cpp index 3c4d01d93b..6984eb8aa0 100644 --- a/tests/waylandclienttest.cpp +++ b/tests/waylandclienttest.cpp @@ -108,12 +108,15 @@ void WaylandClientTest::setupRegistry(Registry *registry) [this, registry](quint32 name) { m_compositor = registry->createCompositor(name, 1, this); m_surface = m_compositor->createSurface(this); + m_transient.surface = m_compositor->createSurface(this); } ); connect(registry, &Registry::shellAnnounced, this, [this, registry](quint32 name) { Shell *shell = registry->createShell(name, 1, this); m_shellSurface = shell->createSurface(m_surface, m_surface); + m_transient.shellSurface = shell->createSurface(m_transient.surface, m_transient.surface); + m_transient.shellSurface->setTransient(m_surface, QPoint(100, 100)); connect(m_shellSurface, &ShellSurface::sizeChanged, this, static_cast(&WaylandClientTest::render)); render(QSize(200, 200)); } @@ -156,6 +159,32 @@ void WaylandClientTest::setupRegistry(Registry *registry) } } } + if (key == KEY_T && state == Keyboard::KeyState::Released) { + if (m_transient.visible) { + m_transient.surface->attachBuffer(Buffer::Ptr()); + m_transient.surface->commit(Surface::CommitFlag::None); + m_transient.visible = false; + } else { + const QSize size(200, 200); + auto buffer = m_shm->getBuffer(size, size.width() * 4).toStrongRef(); + buffer->setUsed(true); + QImage image(buffer->address(), size.width(), size.height(), QImage::Format_ARGB32_Premultiplied); + image.fill(s_colors[s_colorIndex]); + + m_transient.surface->attachBuffer(*buffer); + m_transient.surface->damage(QRect(QPoint(0, 0), size)); + m_transient.surface->commit(Surface::CommitFlag::None); + buffer->setUsed(false); + m_transient.visible = true; + } + } + if (key == KEY_K && state == Keyboard::KeyState::Released) { + delete m_shellSurface; + m_shellSurface = nullptr; + delete m_surface; + m_surface = nullptr; + m_connectionThreadObject->flush(); + } } ); } diff --git a/tests/waylandclienttest.h b/tests/waylandclienttest.h index a3455b13f1..7d8b54a88a 100644 --- a/tests/waylandclienttest.h +++ b/tests/waylandclienttest.h @@ -64,6 +64,11 @@ private: KWayland::Client::ShellSurface *m_shellSurface; QSize m_currentSize; QTimer *m_timer; + struct { + KWayland::Client::Surface *surface = nullptr; + KWayland::Client::ShellSurface *shellSurface = nullptr; + bool visible = false; + } m_transient; }; #endif