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
This commit is contained in:
David Edmundson 2017-07-28 09:50:52 +01:00
parent c6b085f5eb
commit e8ef0ea68f

View file

@ -537,24 +537,37 @@ void TestWaylandRegistry::testDestroy()
QVERIFY(connectedSpy.wait()); QVERIFY(connectedSpy.wait());
Registry registry; Registry registry;
QSignalSpy shellAnnouncedSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
QVERIFY(!registry.isValid()); QVERIFY(!registry.isValid());
registry.create(connection.display()); registry.create(&connection);
registry.setup(); registry.setup();
QVERIFY(registry.isValid()); QVERIFY(registry.isValid());
connect(&connection, &ConnectionThread::connectionDied, &registry, &Registry::destroy); //create some arbitrary Interface
shellAnnouncedSpy.wait();
QScopedPointer<Shell> shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version, &registry));
QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied())); QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied()));
QSignalSpy registryDiedSpy(&registry, SIGNAL(registryDestroyed()));
QVERIFY(connectionDiedSpy.isValid()); QVERIFY(connectionDiedSpy.isValid());
QVERIFY(registryDiedSpy.isValid());
delete m_display; delete m_display;
m_display = nullptr; m_display = nullptr;
QVERIFY(connectionDiedSpy.wait()); QVERIFY(connectionDiedSpy.wait());
QVERIFY(connectionDiedSpy.count() == 1);
QVERIFY(registryDiedSpy.count() == 1);
// now the registry should be destroyed; // now the registry should be destroyed;
QVERIFY(!registry.isValid()); QVERIFY(!registry.isValid());
// calling destroy again should not fail // calling destroy again should not fail
registry.destroy(); registry.destroy();
shell->destroy();
} }
void TestWaylandRegistry::testGlobalSync() void TestWaylandRegistry::testGlobalSync()