From f40a68f58dd1fc8b4cbd89434559c3400e7bd39b Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Thu, 5 Dec 2024 12:23:41 +0000 Subject: [PATCH] wina11y: Drop unnecessary exception handling Window::GetSystemData should never throw an exception, so there's no need for exception handling here. Also, return early if the system data is null. Change-Id: I65794f10019d0c2fb5cc7150500b551c31cc2a08 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177887 Reviewed-by: Michael Weghorn Tested-by: Jenkins --- .../source/service/AccTopWindowListener.cxx | 56 ++++++++----------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/winaccessibility/source/service/AccTopWindowListener.cxx b/winaccessibility/source/service/AccTopWindowListener.cxx index 40d9ba8755c1..181d7d8f4fa2 100644 --- a/winaccessibility/source/service/AccTopWindowListener.cxx +++ b/winaccessibility/source/service/AccTopWindowListener.cxx @@ -47,45 +47,37 @@ void AccTopWindowListener::HandleWindowOpened( css::accessibility::XAccessible* else if (auto pvclxcomponent = dynamic_cast(pAccessible)) window = pvclxcomponent->GetWindow(); assert(window); - // The SalFrame of window may be destructed at this time - const SystemEnvData* systemdata = nullptr; - try - { - systemdata = window->GetSystemData(); - } - catch(...) - { - systemdata = nullptr; - } + + const SystemEnvData* pSystemData = window->GetSystemData(); + if (!pSystemData) + return; + Reference xContext = pAccessible->getAccessibleContext(); if(!xContext.is()) return; // add all listeners - if (systemdata != nullptr) + m_aAccObjectManager.SaveTopWindowHandle(pSystemData->hWnd, pAccessible); + + AddAllListeners(pAccessible, nullptr, pSystemData->hWnd); + + if( window->GetStyle() & WB_MOVEABLE ) + m_aAccObjectManager.IncreaseState( pAccessible, static_cast(-1) /* U_MOVEBLE */ ); + + short role = xContext->getAccessibleRole(); + + if (role == css::accessibility::AccessibleRole::POPUP_MENU || + role == css::accessibility::AccessibleRole::MENU ) { - m_aAccObjectManager.SaveTopWindowHandle(systemdata->hWnd, pAccessible); + m_aAccObjectManager.NotifyAccEvent(pAccessible, UnoMSAAEvent::MENUPOPUPSTART); + } - AddAllListeners(pAccessible,nullptr,systemdata->hWnd); - - if( window->GetStyle() & WB_MOVEABLE ) - m_aAccObjectManager.IncreaseState( pAccessible, static_cast(-1) /* U_MOVEBLE */ ); - - short role = xContext->getAccessibleRole(); - - if (role == css::accessibility::AccessibleRole::POPUP_MENU || - role == css::accessibility::AccessibleRole::MENU ) - { - m_aAccObjectManager.NotifyAccEvent(pAccessible, UnoMSAAEvent::MENUPOPUPSTART); - } - - if (role == css::accessibility::AccessibleRole::FRAME || - role == css::accessibility::AccessibleRole::DIALOG || - role == css::accessibility::AccessibleRole::WINDOW || - role == css::accessibility::AccessibleRole::ALERT) - { - m_aAccObjectManager.NotifyAccEvent(pAccessible, UnoMSAAEvent::SHOW); - } + if (role == css::accessibility::AccessibleRole::FRAME || + role == css::accessibility::AccessibleRole::DIALOG || + role == css::accessibility::AccessibleRole::WINDOW || + role == css::accessibility::AccessibleRole::ALERT) + { + m_aAccObjectManager.NotifyAccEvent(pAccessible, UnoMSAAEvent::SHOW); } }