From ea4de855532d6905fc29b0a220b1e9b45e7ec7a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 9 May 2016 16:01:49 +0200 Subject: [PATCH] Destroy static Client helper window before application goes down Summary: Client uses a static Xcb::Window helper. This so far didn't get explicitly destroyed, so the application finalize cleaned it up. To destroy the window the xcb_connection_t* is used which the QGuiApplication already destroyed. This change ensures that the window gets destroyed before the xcb connection gets destroyed. In addition an assert is added to KWin::connection() to ensure that we still have the QGuiApplication::instance() when it's invoked. This way we'll notice if we have more cases where we call into xcb after the application went down. Reviewers: #plasma Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1573 --- client.cpp | 5 +++++ client.h | 2 ++ libkwineffects/kwinglobals.h | 1 + workspace.cpp | 1 + 4 files changed, 9 insertions(+) diff --git a/client.cpp b/client.cpp index 5c49b1691d..2e6966643e 100644 --- a/client.cpp +++ b/client.cpp @@ -630,6 +630,11 @@ void Client::updateShape() static Xcb::Window shape_helper_window(XCB_WINDOW_NONE); +void Client::cleanupX11() +{ + shape_helper_window.reset(); +} + void Client::updateInputShape() { if (hiddenPreview()) // Sets it to none, don't change diff --git a/client.h b/client.h index 7a28b547ba..08e25abe3a 100644 --- a/client.h +++ b/client.h @@ -355,6 +355,8 @@ public: **/ void showOnScreenEdge(); + static void cleanupX11(); + public Q_SLOTS: void closeWindow() override; void updateCaption(); diff --git a/libkwineffects/kwinglobals.h b/libkwineffects/kwinglobals.h index 18b78f44e7..3ae0d36b54 100644 --- a/libkwineffects/kwinglobals.h +++ b/libkwineffects/kwinglobals.h @@ -144,6 +144,7 @@ KWIN_EXPORT xcb_connection_t *connection() if (!s_con) { s_con = reinterpret_cast(qApp->property("x11Connection").value()); } + Q_ASSERT(qApp); return s_con; } diff --git a/workspace.cpp b/workspace.cpp index a179a198db..a179889b22 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -448,6 +448,7 @@ Workspace::~Workspace() m_allClients.removeAll(c); desktops.removeAll(c); } + Client::cleanupX11(); for (UnmanagedList::iterator it = unmanaged.begin(), end = unmanaged.end(); it != end; ++it) (*it)->release(ReleaseReason::KWinShutsDown); xcb_delete_property(connection(), rootWindow(), atoms->kwin_running);