From e8ef0ea68fc01c7b97c06efdf2944743e5e122ea Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 28 Jul 2017 09:50:52 +0100 Subject: [PATCH] Destroy all kwayland objects created by registry when it is destroyed Summary: Currently one has to connect every object manually to connectionDied, which is something we can do for them. If the user also has a connection, the second will just no-op. This fixes objects that linger longer than the QApp. Reviewers: graesslin Reviewed By: graesslin Subscribers: graesslin, plasma-devel, #frameworks Tags: #plasma_on_wayland, #frameworks Differential Revision: https://phabricator.kde.org/D6727 --- .../autotests/client/test_wayland_registry.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/wayland/autotests/client/test_wayland_registry.cpp b/src/wayland/autotests/client/test_wayland_registry.cpp index f109d7ded5..7e050ed755 100644 --- a/src/wayland/autotests/client/test_wayland_registry.cpp +++ b/src/wayland/autotests/client/test_wayland_registry.cpp @@ -537,24 +537,37 @@ void TestWaylandRegistry::testDestroy() QVERIFY(connectedSpy.wait()); Registry registry; + QSignalSpy shellAnnouncedSpy(®istry, SIGNAL(shellAnnounced(quint32,quint32))); + QVERIFY(!registry.isValid()); - registry.create(connection.display()); + registry.create(&connection); registry.setup(); QVERIFY(registry.isValid()); - connect(&connection, &ConnectionThread::connectionDied, ®istry, &Registry::destroy); + //create some arbitrary Interface + shellAnnouncedSpy.wait(); + QScopedPointer shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version, ®istry)); + QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied())); + QSignalSpy registryDiedSpy(®istry, SIGNAL(registryDestroyed())); + QVERIFY(connectionDiedSpy.isValid()); + QVERIFY(registryDiedSpy.isValid()); + delete m_display; m_display = nullptr; QVERIFY(connectionDiedSpy.wait()); + QVERIFY(connectionDiedSpy.count() == 1); + QVERIFY(registryDiedSpy.count() == 1); + // now the registry should be destroyed; QVERIFY(!registry.isValid()); // calling destroy again should not fail registry.destroy(); + shell->destroy(); } void TestWaylandRegistry::testGlobalSync()