From a492fa38661f0791ca72ff87a112117e5dbd5965 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Mon, 5 Jan 2026 16:21:05 +0100 Subject: [PATCH] desktop/window: catch bad any cast tokens --- src/desktop/view/Window.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/desktop/view/Window.cpp b/src/desktop/view/Window.cpp index a22f4a9d..4a2d46a9 100644 --- a/src/desktop/view/Window.cpp +++ b/src/desktop/view/Window.cpp @@ -463,11 +463,13 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) { if (TOKEN) { if (*PINITIALWSTRACKING == 2) { // persistent - SInitialWorkspaceToken token = std::any_cast(TOKEN->m_data); - if (token.primaryOwner == m_self) { - token.workspace = pWorkspace->getConfigName(); - TOKEN->m_data = token; - } + try { + SInitialWorkspaceToken token = std::any_cast(TOKEN->m_data); + if (token.primaryOwner == m_self) { + token.workspace = pWorkspace->getConfigName(); + TOKEN->m_data = token; + } + } catch (const std::bad_any_cast& e) { ; } } } } @@ -553,9 +555,11 @@ void CWindow::onUnmap() { if (TOKEN) { if (*PINITIALWSTRACKING == 2) { // persistent token, but the first window got removed so the token is gone - SInitialWorkspaceToken token = std::any_cast(TOKEN->m_data); - if (token.primaryOwner == m_self) - g_pTokenManager->removeToken(TOKEN); + try { + SInitialWorkspaceToken token = std::any_cast(TOKEN->m_data); + if (token.primaryOwner == m_self) + g_pTokenManager->removeToken(TOKEN); + } catch (const std::bad_any_cast& e) { g_pTokenManager->removeToken(TOKEN); } } } }