diff --git a/autotests/integration/kwin_wayland_test.cpp b/autotests/integration/kwin_wayland_test.cpp --- a/autotests/integration/kwin_wayland_test.cpp +++ b/autotests/integration/kwin_wayland_test.cpp @@ -76,6 +76,7 @@ WaylandTestApplication::~WaylandTestApplication() { + setTerminating(); kwinApp()->platform()->setOutputsEnabled(false); // need to unload all effects prior to destroying X connection as they might do X calls // also before destroy Workspace, as effects might call into Workspace diff --git a/composite.cpp b/composite.cpp --- a/composite.cpp +++ b/composite.cpp @@ -156,6 +156,10 @@ void Compositor::setup() { + if (kwinApp()->isTerminating()) { + // don't setup while KWin is terminating. An event to restart might be lingering in the event queue due to graphics reset + return; + } if (hasScene()) return; if (m_suspended) { diff --git a/main.h b/main.h --- a/main.h +++ b/main.h @@ -188,6 +188,10 @@ return m_platform; } + bool isTerminating() const { + return m_terminating; + } + static void setupMalloc(); static void setupLocalizedString(); @@ -231,6 +235,10 @@ } void destroyAtoms(); + void setTerminating() { + m_terminating = true; + } + protected: QString m_originalSessionKey; static int crashes; @@ -252,6 +260,7 @@ bool m_useKActivities = true; #endif Platform *m_platform = nullptr; + bool m_terminating = false; }; inline static Application *kwinApp() diff --git a/main_wayland.cpp b/main_wayland.cpp --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -129,6 +129,7 @@ ApplicationWayland::~ApplicationWayland() { + setTerminating(); if (!waylandServer()) { return; } diff --git a/main_x11.cpp b/main_x11.cpp --- a/main_x11.cpp +++ b/main_x11.cpp @@ -187,6 +187,7 @@ ApplicationX11::~ApplicationX11() { + setTerminating(); destroyCompositor(); destroyWorkspace(); if (!owner.isNull() && owner->ownerWindow() != XCB_WINDOW_NONE) // If there was no --replace (no new WM)