From 3be016fba4936df9aa3a48069de5ce2af60c8790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 18 Nov 2015 10:29:10 +0100 Subject: [PATCH] [wayland] Destroy all ClientConnections on tear down Ensures that all Wayland objects are destroyed and the cleanup handling is performed before tearing down the Compositor. This fixes for example a crash if a Surface with a Shadow is still around at tear down. --- autotests/wayland/kwin_wayland_test.cpp | 2 +- main_wayland.cpp | 2 +- wayland_server.cpp | 10 ++++++++++ wayland_server.h | 3 ++- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/autotests/wayland/kwin_wayland_test.cpp b/autotests/wayland/kwin_wayland_test.cpp index ad651bee9e..566b234bfd 100644 --- a/autotests/wayland/kwin_wayland_test.cpp +++ b/autotests/wayland/kwin_wayland_test.cpp @@ -73,7 +73,7 @@ WaylandTestApplication::~WaylandTestApplication() } waylandServer()->destroyXWaylandConnection(); } - waylandServer()->destroyInternalConnection(); + waylandServer()->terminateClientConnections(); destroyCompositor(); } diff --git a/main_wayland.cpp b/main_wayland.cpp index 10d14d03f7..9a15e99964 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -97,7 +97,7 @@ ApplicationWayland::~ApplicationWayland() } waylandServer()->destroyXWaylandConnection(); } - waylandServer()->destroyInternalConnection(); + waylandServer()->terminateClientConnections(); destroyCompositor(); } diff --git a/wayland_server.cpp b/wayland_server.cpp index 4036a317ae..b026014188 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -91,6 +91,16 @@ void WaylandServer::destroyInternalConnection() } } +void WaylandServer::terminateClientConnections() +{ + destroyInternalConnection(); + destroyInputMethodConnection(); + const auto connections = m_display->connections(); + for (auto it = connections.begin(); it != connections.end(); ++it) { + (*it)->destroy(); + } +} + void WaylandServer::init(const QByteArray &socketName, InitalizationFlags flags) { m_initFlags = flags; diff --git a/wayland_server.h b/wayland_server.h index b6514b6fe8..ba40d908c0 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -72,6 +72,7 @@ public: virtual ~WaylandServer(); void init(const QByteArray &socketName = QByteArray(), InitalizationFlags flags = InitalizationFlag::NoOptions); void initOutputs(); + void terminateClientConnections(); KWayland::Server::Display *display() { return m_display; @@ -123,7 +124,6 @@ public: bool isScreenLocked() const; void createInternalConnection(); - void destroyInternalConnection(); void initWorkspace(); KWayland::Server::ClientConnection *xWaylandConnection() const { @@ -156,6 +156,7 @@ Q_SIGNALS: private: quint16 createClientId(KWayland::Server::ClientConnection *c); + void destroyInternalConnection(); KWayland::Server::Display *m_display = nullptr; KWayland::Server::CompositorInterface *m_compositor = nullptr; KWayland::Server::SeatInterface *m_seat = nullptr;