desktop/window: catch bad any cast tokens

This commit is contained in:
Vaxry 2026-01-05 16:21:05 +01:00 committed by Vaxry
parent e165f84184
commit a492fa3866

View file

@ -463,11 +463,13 @@ void CWindow::moveToWorkspace(PHLWORKSPACE pWorkspace) {
if (TOKEN) { if (TOKEN) {
if (*PINITIALWSTRACKING == 2) { if (*PINITIALWSTRACKING == 2) {
// persistent // persistent
SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->m_data); try {
if (token.primaryOwner == m_self) { SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->m_data);
token.workspace = pWorkspace->getConfigName(); if (token.primaryOwner == m_self) {
TOKEN->m_data = token; 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 (TOKEN) {
if (*PINITIALWSTRACKING == 2) { if (*PINITIALWSTRACKING == 2) {
// persistent token, but the first window got removed so the token is gone // persistent token, but the first window got removed so the token is gone
SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->m_data); try {
if (token.primaryOwner == m_self) SInitialWorkspaceToken token = std::any_cast<SInitialWorkspaceToken>(TOKEN->m_data);
g_pTokenManager->removeToken(TOKEN); if (token.primaryOwner == m_self)
g_pTokenManager->removeToken(TOKEN);
} catch (const std::bad_any_cast& e) { g_pTokenManager->removeToken(TOKEN); }
} }
} }
} }