diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp index fe07f1de23..fa674c9e5d 100644 --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -83,18 +83,23 @@ WaylandTestApplication::~WaylandTestApplication() if (effects) { static_cast(effects)->unloadAllEffects(); } - if (m_xwayland) { - // needs to be done before workspace gets destroyed - m_xwayland->prepareDestroy(); - } - destroyWorkspace(); + + // Kill Xwayland before terminating its connection. + delete m_xwayland; + m_xwayland = nullptr; + + // Terminate all client connections before Workspace is destroyed. + // Shell clients need to access RuleBook whose lifetime is bound + // to the Workspace class. + waylandServer()->terminateClientConnections(); waylandServer()->dispatch(); + + destroyWorkspace(); + if (QStyle *s = style()) { s->unpolish(this); } - // kill Xwayland before terminating its connection - delete m_xwayland; - waylandServer()->terminateClientConnections(); + destroyCompositor(); } diff --git a/main_wayland.cpp b/main_wayland.cpp index 40336ae741..60d6a7b4d4 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -128,20 +128,23 @@ ApplicationWayland::~ApplicationWayland() if (effects) { static_cast(effects)->unloadAllEffects(); } - if (m_xwayland) { - // needs to be done before workspace gets destroyed - m_xwayland->prepareDestroy(); - } - destroyWorkspace(); + + // Kill Xwayland before terminating its connection. + delete m_xwayland; + m_xwayland = nullptr; + + // Terminate all client connections before Workspace is destroyed. + // Shell clients need to access RuleBook whose lifetime is bound + // to the Workspace class. + waylandServer()->terminateClientConnections(); waylandServer()->dispatch(); + destroyWorkspace(); + if (QStyle *s = style()) { s->unpolish(this); } - // kill Xwayland before terminating its connection - delete m_xwayland; - m_xwayland = nullptr; - waylandServer()->terminateClientConnections(); + destroyCompositor(); } diff --git a/shell_client.cpp b/shell_client.cpp index fd2edaef19..b24c675b64 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -425,11 +425,9 @@ void ShellClient::destroyClient() if (isMoveResize()) { leaveMoveResize(); } - Deleted *del = nullptr; - if (workspace()) { - del = Deleted::create(this); - } - emit windowClosed(this, del); + + Deleted *deleted = Deleted::create(this); + emit windowClosed(this, deleted); // Remove Force Temporarily rules. RuleBook::self()->discardUsed(this, true); @@ -437,25 +435,22 @@ void ShellClient::destroyClient() destroyWindowManagementInterface(); destroyDecoration(); - if (workspace()) { - StackingUpdatesBlocker blocker(workspace()); - if (transientFor()) { - transientFor()->removeTransient(this); - } - for (auto it = transients().constBegin(); it != transients().constEnd();) { - if ((*it)->transientFor() == this) { - removeTransient(*it); - it = transients().constBegin(); // restart, just in case something more has changed with the list - } else { - ++it; - } + StackingUpdatesBlocker blocker(workspace()); + if (transientFor()) { + transientFor()->removeTransient(this); + } + for (auto it = transients().constBegin(); it != transients().constEnd();) { + if ((*it)->transientFor() == this) { + removeTransient(*it); + it = transients().constBegin(); // restart, just in case something more has changed with the list + } else { + ++it; } } + waylandServer()->removeClient(this); - if (del) { - del->unrefWindow(); - } + deleted->unrefWindow(); m_shellSurface = nullptr; m_xdgShellSurface = nullptr; m_xdgShellPopup = nullptr; diff --git a/xwl/xwayland.cpp b/xwl/xwayland.cpp index 5f17d3923c..35fbe1dfe6 100644 --- a/xwl/xwayland.cpp +++ b/xwl/xwayland.cpp @@ -88,6 +88,9 @@ Xwayland::Xwayland(ApplicationWaylandAbstract *app, QObject *parent) Xwayland::~Xwayland() { + delete m_dataBridge; + m_dataBridge = nullptr; + disconnect(m_xwaylandFailConnection); if (m_app->x11Connection()) { Xcb::setInputFocus(XCB_INPUT_FOCUS_POINTER_ROOT); @@ -178,12 +181,6 @@ void Xwayland::init() close(pipeFds[1]); } -void Xwayland::prepareDestroy() -{ - delete m_dataBridge; - m_dataBridge = nullptr; -} - void Xwayland::createX11Connection() { int screenNumber = 0; diff --git a/xwl/xwayland.h b/xwl/xwayland.h index b759e6af55..ef228ee312 100644 --- a/xwl/xwayland.h +++ b/xwl/xwayland.h @@ -47,7 +47,6 @@ public: ~Xwayland() override; void init(); - void prepareDestroy(); xcb_screen_t *xcbScreen() const { return m_xcbScreen;