From ef9bfcdbc67667f217ea01886ee728f8d1cbeb19 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Fri, 21 Jul 2023 18:12:14 +0200 Subject: a11y: Drop obsolete check for empty Reference The default Reference ctor always creates an empty Reference, so checking for that here doesn't make any more sense here since commit 77ea0535271d3fb3d49c8d916ecf80e0a7f70653 Date: Wed Sep 18 15:54:23 2019 +0200 accessibility: fix leak of AccessibleListBoxEntry (`git -w shows it's only the check that was dropped besides adapting indendation accordingly.) Change-Id: I18cda45f8730b0234eed0edf31fc6e0a32b1cb9f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154745 Tested-by: Jenkins Reviewed-by: Michael Weghorn --- .../source/extended/accessiblelistboxentry.cxx | 57 ++++++++++------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/accessibility/source/extended/accessiblelistboxentry.cxx b/accessibility/source/extended/accessiblelistboxentry.cxx index 189cb60d56a8..63d808b39cd2 100644 --- a/accessibility/source/extended/accessiblelistboxentry.cxx +++ b/accessibility/source/extended/accessiblelistboxentry.cxx @@ -319,36 +319,33 @@ namespace accessibility Reference< XAccessible > AccessibleListBoxEntry::implGetParentAccessible( ) const { Reference< XAccessible > xParent; - if ( !xParent.is() ) - { - assert( m_aEntryPath.size() ); // invalid path - if ( m_aEntryPath.size() == 1 ) - { // we're a top level entry - // -> our parent is the tree listbox itself - if ( m_pTreeListBox ) - xParent = m_pTreeListBox->GetAccessible( ); - } - else - { // we have an entry as parent -> get its accessible - - // shorten our access path by one - std::deque< sal_Int32 > aParentPath( m_aEntryPath ); - aParentPath.pop_back(); - - // get the entry for this shortened access path - SvTreeListEntry* pParentEntry = m_pTreeListBox->GetEntryFromPath( aParentPath ); - OSL_ENSURE( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" ); - - if ( pParentEntry ) - pParentEntry = m_pTreeListBox->GetParent(pParentEntry); - if ( pParentEntry ) - { - uno::Reference xListBox(m_wListBox); - assert(xListBox.is()); - return m_rListBox.implGetAccessible(*pParentEntry); - // the AccessibleListBoxEntry class will create its parent - // when needed - } + assert( m_aEntryPath.size() ); // invalid path + if ( m_aEntryPath.size() == 1 ) + { // we're a top level entry + // -> our parent is the tree listbox itself + if ( m_pTreeListBox ) + xParent = m_pTreeListBox->GetAccessible( ); + } + else + { // we have an entry as parent -> get its accessible + + // shorten our access path by one + std::deque< sal_Int32 > aParentPath( m_aEntryPath ); + aParentPath.pop_back(); + + // get the entry for this shortened access path + SvTreeListEntry* pParentEntry = m_pTreeListBox->GetEntryFromPath( aParentPath ); + OSL_ENSURE( pParentEntry, "AccessibleListBoxEntry::implGetParentAccessible: could not obtain a parent entry!" ); + + if ( pParentEntry ) + pParentEntry = m_pTreeListBox->GetParent(pParentEntry); + if ( pParentEntry ) + { + uno::Reference xListBox(m_wListBox); + assert(xListBox.is()); + return m_rListBox.implGetAccessible(*pParentEntry); + // the AccessibleListBoxEntry class will create its parent + // when needed } } -- cgit