comphelper/source/misc/accessiblewrapper.cxx | 47 +++++++++------------------ 1 file changed, 17 insertions(+), 30 deletions(-)
New commits: commit 363ee9fc34c5a6a04671450025fab7940032867d Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed May 21 20:29:57 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 22 05:53:02 2025 +0200 comphelper a11y: Drop unreachable OSL_FAIL The return value of std::map::emplace is [1]: > A pair consisting of an iterator to the inserted element > (or to the element that prevented the insertion) and a bool > value set to true if and only if the insertion took place. If the element were already present in the map, the AccessibleMap::const_iterator aPos = m_aChildrenMap.find( _rxKey ); if ( m_aChildrenMap.end() != aPos ) return aPos->second; code path above would have been taken, so there's no way that this OSL_FAIL can be reached, which is even more clearly visible since Change-Id: I3df5d430c16d9d5b7c836926928d023e45d85d45 Author: Michael Weghorn <m.wegh...@posteo.de> Date: Wed May 21 20:25:04 2025 +0200 a11y: Flatten OWrappedAccessibleChildrenManager::getAccessibleWrapperFor [1] https://en.cppreference.com/w/cpp/container/map/emplace Change-Id: I9dbeb22bac11624533ef7b93da36adcd7038bff7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185631 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index 84490f7f2e19..d5d95dda6532 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -102,13 +102,7 @@ Reference< XAccessible > OWrappedAccessibleChildrenManager::getAccessibleWrapper // see if we do cache children if ( !m_bTransientChildren ) { - if (!m_aChildrenMap.emplace( _rxKey, xValue ).second) - { - OSL_FAIL( - "OWrappedAccessibleChildrenManager::" - "getAccessibleWrapperFor: element was already" - " inserted!" ); - } + m_aChildrenMap.emplace(_rxKey, xValue); // listen for disposals of inner children - this may happen when the inner context // is the owner for the inner children (it will dispose these children, and of course commit 57d41c3a9b40163c1c0076da1e896f6f479351bd Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed May 21 20:25:04 2025 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu May 22 05:52:57 2025 +0200 a11y: Flatten OWrappedAccessibleChildrenManager::getAccessibleWrapperFor Return early to reduce nesting level. Change-Id: I3df5d430c16d9d5b7c836926928d023e45d85d45 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185630 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/comphelper/source/misc/accessiblewrapper.cxx b/comphelper/source/misc/accessiblewrapper.cxx index 0ed9a96daba7..84490f7f2e19 100644 --- a/comphelper/source/misc/accessiblewrapper.cxx +++ b/comphelper/source/misc/accessiblewrapper.cxx @@ -86,43 +86,36 @@ void OWrappedAccessibleChildrenManager::invalidateAll( ) Reference< XAccessible > OWrappedAccessibleChildrenManager::getAccessibleWrapperFor( const Reference< XAccessible >& _rxKey ) { - rtl::Reference< OAccessibleWrapper > xValue; - if( !_rxKey.is() ) - { - // fprintf( stderr, "It was this path that was crashing stuff " ); - return xValue; - } + return {}; // do we have this child in the cache? AccessibleMap::const_iterator aPos = m_aChildrenMap.find( _rxKey ); if ( m_aChildrenMap.end() != aPos ) - { - xValue = aPos->second; - } - else - { // not found in the cache, and allowed to create - // -> new wrapper - xValue = new OAccessibleWrapper( m_xContext, _rxKey, m_aOwningAccessible ); + return aPos->second; - // see if we do cache children - if ( !m_bTransientChildren ) - { - if (!m_aChildrenMap.emplace( _rxKey, xValue ).second) - { - OSL_FAIL( - "OWrappedAccessibleChildrenManager::" - "getAccessibleWrapperFor: element was already" - " inserted!" ); - } + // not found in the cache, and allowed to create + // -> new wrapper + rtl::Reference<OAccessibleWrapper> xValue + = new OAccessibleWrapper(m_xContext, _rxKey, m_aOwningAccessible); - // listen for disposals of inner children - this may happen when the inner context - // is the owner for the inner children (it will dispose these children, and of course - // not our wrapper for these children) - Reference< XComponent > xComp( _rxKey, UNO_QUERY ); - if ( xComp.is() ) - xComp->addEventListener( this ); + // see if we do cache children + if ( !m_bTransientChildren ) + { + if (!m_aChildrenMap.emplace( _rxKey, xValue ).second) + { + OSL_FAIL( + "OWrappedAccessibleChildrenManager::" + "getAccessibleWrapperFor: element was already" + " inserted!" ); } + + // listen for disposals of inner children - this may happen when the inner context + // is the owner for the inner children (it will dispose these children, and of course + // not our wrapper for these children) + Reference< XComponent > xComp( _rxKey, UNO_QUERY ); + if ( xComp.is() ) + xComp->addEventListener( this ); } return xValue;