summaryrefslogtreecommitdiff
path: root/src/desktop/Workspace.cpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2024-04-08 19:28:11 +0200
committerGitHub <noreply@github.com>2024-04-08 18:28:11 +0100
commit125a8f7e0734d9310f6d046363828e33b67e972b (patch)
tree44e3a71cfef5f9cc228410b032ed5c3e8a705b9d /src/desktop/Workspace.cpp
parent63e3668529f6c06478ec288723d0ba46374c4bc5 (diff)
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.
Diffstat (limited to 'src/desktop/Workspace.cpp')
-rw-r--r--src/desktop/Workspace.cpp14
1 files changed, 9 insertions, 5 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);
-
- g_pEventManager->postEvent({"destroyworkspace", m_szName});
- g_pEventManager->postEvent({"destroyworkspacev2", std::format("{},{}", m_iID, m_szName)});
- EMIT_HOOK_EVENT("destroyWorkspace", this);
+ // 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);
+
+ 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) {