From 125a8f7e0734d9310f6d046363828e33b67e972b Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Mon, 8 Apr 2024 19:28:11 +0200 Subject: [PATCH] workspace: fix crash on destruction of compositor (#5495) when the compositor destructs because of exiting hyprland the hookmanager and eventmanager is already destroyed, add an if check in the destructor of workspace so it doesnt segfault on exit. --- src/desktop/Workspace.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/desktop/Workspace.cpp b/src/desktop/Workspace.cpp index 734b7c8e..cbc4b16e 100644 --- a/src/desktop/Workspace.cpp +++ b/src/desktop/Workspace.cpp @@ -57,11 +57,15 @@ CWorkspace::~CWorkspace() { Debug::log(LOG, "Destroying workspace ID {}", m_iID); - g_pHookSystem->unhook(m_pFocusedWindowHook); + // check if g_pHookSystem and g_pEventManager exist, they might be destroyed as in when the compositor is closing. + if (g_pHookSystem) + g_pHookSystem->unhook(m_pFocusedWindowHook); - g_pEventManager->postEvent({"destroyworkspace", m_szName}); - g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)}); - EMIT_HOOK_EVENT("destroyWorkspace", this); + if (g_pEventManager) { + g_pEventManager->postEvent({"destroyworkspace", m_szName}); + g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)}); + EMIT_HOOK_EVENT("destroyWorkspace", this); + } } void CWorkspace::startAnim(bool in, bool left, bool instant) {