From 3f4e73346845092a4fc555f03888c2398c299e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Tue, 10 Nov 2015 14:27:03 +0100 Subject: [PATCH] [wayland] Ensure we can tear down ShellClient after Workspace is destroyed This can happen during tear down of the internal shell clients. --- shell_client.cpp | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/shell_client.cpp b/shell_client.cpp index 4c1f352137..e6a8b061b1 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -155,24 +155,31 @@ ShellClient::~ShellClient() = default; void ShellClient::destroyClient() { m_closing = true; - Deleted *del = Deleted::create(this); + Deleted *del = nullptr; + if (workspace()) { + del = Deleted::create(this); + } emit windowClosed(this, del); - 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; + 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; + } } } waylandServer()->removeClient(this); - del->unrefWindow(); + if (del) { + del->unrefWindow(); + } m_shellSurface = nullptr; deleteClient(this); }