From c6b085f5eba90f1cffc241262ca748b93da97688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sat, 8 Jul 2017 14:34:20 +0200 Subject: [PATCH] [client] Track all created ConnectionThreads and add API to access them Summary: This is change needed by KWin. KWin has the problem that it destroys its internal Wayland connection (KWin as client for KWin as server) before shutting down the application. Other external libraries loaded into KWin (e.g. breeze window decoration) are unloaded later on, then try to clean up their Wayland resources and crash KWin due to accessing a no longer valid Wayland connection. With the help of this new API KWin can access all connections during the clean up and destroy them before shutting down the Wayland server and thus exit cleanly. Reviewers: #frameworks, #plasma, #kwin Subscribers: plasma-devel Tags: #plasma_on_wayland, #frameworks Differential Revision: https://phabricator.kde.org/D6569 --- .../autotests/client/test_wayland_connection_thread.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wayland/autotests/client/test_wayland_connection_thread.cpp b/src/wayland/autotests/client/test_wayland_connection_thread.cpp index 67002d0417..f7529f7304 100644 --- a/src/wayland/autotests/client/test_wayland_connection_thread.cpp +++ b/src/wayland/autotests/client/test_wayland_connection_thread.cpp @@ -78,7 +78,9 @@ void TestWaylandConnectionThread::cleanup() void TestWaylandConnectionThread::testInitConnectionNoThread() { + QVERIFY(KWayland::Client::ConnectionThread::connections().isEmpty()); QScopedPointer connection(new KWayland::Client::ConnectionThread); + QVERIFY(KWayland::Client::ConnectionThread::connections().contains(connection.data())); QCOMPARE(connection->socketName(), QStringLiteral("wayland-0")); connection->setSocketName(s_socketName); QCOMPARE(connection->socketName(), s_socketName); @@ -90,6 +92,9 @@ void TestWaylandConnectionThread::testInitConnectionNoThread() QCOMPARE(connectedSpy.count(), 1); QCOMPARE(failedSpy.count(), 0); QVERIFY(connection->display()); + + connection.reset(); + QVERIFY(KWayland::Client::ConnectionThread::connections().isEmpty()); } void TestWaylandConnectionThread::testConnectionFailure()