accessibility/inc/standard/vclxaccessiblelist.hxx | 2 - accessibility/source/standard/vclxaccessiblelist.cxx | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-)
New commits: commit 5587c422fa0f8f93849cb2eabbf5594e11819b50 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Sep 4 17:19:03 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Sep 14 18:23:19 2023 +0200 tdf#157088 a11y: Dispose list items with list Don't only clear, but also dispose the list items when the `VCLXAccessibleList` gets disposed. Interestingly, there was already a comment saying // Dispose all items in the list. , but that wasn't done so far... Fixes a crash on exit with the below backtrace after using the font color toolbox item with the qt6 VCL plugin and Orca running: 1 __pthread_kill_implementation pthread_kill.c 44 0x7fe2a2ea80fc 2 __pthread_kill_internal pthread_kill.c 78 0x7fe2a2ea815f 3 __GI_raise raise.c 26 0x7fe2a2e5a472 4 __GI_abort abort.c 79 0x7fe2a2e444b2 5 __assert_fail_base assert.c 92 0x7fe2a2e443d5 6 __assert_fail assert.c 101 0x7fe2a2e533a2 7 (anonymous namespace)::implLookupClient accessibleeventnotifier.cxx 140 0x7fe2a21138a4 8 comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing accessibleeventnotifier.cxx 185 0x7fe2a2113bb8 9 VCLXAccessibleListItem::disposing vclxaccessiblelistitem.cxx 164 0x7fe26870cb58 10 cppu::WeakAggComponentImplHelperBase::dispose implbase.cxx 230 0x7fe2a1c755e3 11 cppu::WeakAggComponentImplHelperBase::release implbase.cxx 204 0x7fe2a1c75312 12 cppu::WeakAggComponentImplHelper6<com::sun::star::accessibility::XAccessible, com::sun::star::accessibility::XAccessibleContext, com::sun::star::accessibility::XAccessibleComponent, com::sun::star::accessibility::XAccessibleEventBroadcaster, com::sun::star::accessibility::XAccessibleText, com::sun::star::lang::XServiceInfo>::release compbase6.hxx 142 0x7fe26870fc0c 13 com::sun::star::uno::Reference<com::sun::star::accessibility::XAccessible>::~Reference Reference.hxx 114 0x7fe28f2428a7 14 QtAccessibleWidget::~QtAccessibleWidget QtAccessibleWidget.hxx 39 0x7fe28f262cf9 15 QtAccessibleWidget::~QtAccessibleWidget QtAccessibleWidget.hxx 39 0x7fe28f262dd0 16 QAccessibleCache::deleteInterface qaccessiblecache.cpp 173 0x7fe28e0c8e4b 17 QAccessibleCache::~QAccessibleCache qaccessiblecache.cpp 31 0x7fe28e0c845c 18 QAccessibleCache::~QAccessibleCache qaccessiblecache.cpp 32 0x7fe28e0c84e2 19 cleanupAccessibleCache qaccessiblecache.cpp 24 0x7fe28e0c83c8 20 qt_call_post_routines qcoreapplication.cpp 327 0x7fe28e9a4593 21 QApplication::~QApplication qapplication.cpp 663 0x7fe28cf9dff6 22 QApplication::~QApplication qapplication.cpp 717 0x7fe28cf9e2f4 23 std::default_delete<QApplication>::operator() unique_ptr.h 99 0x7fe28f2cf3ae 24 std::__uniq_ptr_impl<QApplication, std::default_delete<QApplication>>::reset unique_ptr.h 211 0x7fe28f2cf7f6 25 std::unique_ptr<QApplication, std::default_delete<QApplication>>::reset unique_ptr.h 509 0x7fe28f2cd72d 26 QtInstance::~QtInstance QtInstance.cxx 273 0x7fe28f2c614f 27 QtInstance::~QtInstance QtInstance.cxx 274 0x7fe28f2c6226 28 DestroySalInstance salplug.cxx 389 0x7fe299a62611 29 DeInitVCL svmain.cxx 600 0x7fe299b41226 30 ImplSVMain svmain.cxx 229 0x7fe299b3f9f7 31 SVMain svmain.cxx 236 0x7fe299b3fa53 32 soffice_main sofficemain.cxx 94 0x7fe2a30a1b5d 33 sal_main main.c 51 0x55c86565c9d4 34 main main.c 49 0x55c86565c9ba Change-Id: I42ddcf5501ddfb363aeae10a86f1c38251e6793b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156522 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit 51de048ae97cbd371457dbc07120e30db9ee4187) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156537 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index 57f9b1eabcb3..101c5815c0ac 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/accessibility/AccessibleRelationType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> +#include <comphelper/types.hxx> #include <o3tl/safeint.hxx> #include <vcl/svapp.hxx> #include <vcl/toolkit/combobox.hxx> @@ -107,6 +108,8 @@ void SAL_CALL VCLXAccessibleList::disposing() VCLXAccessibleComponent::disposing(); // Dispose all items in the list. + for (Reference<XAccessible>& rxChild : m_aAccessibleChildren) + comphelper::disposeComponent(rxChild); m_aAccessibleChildren.clear(); commit f1df57c29aacdd7f56ecd33976c8a6bf6858b918 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Mon Sep 4 17:03:47 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Thu Sep 14 18:23:08 2023 +0200 tdf#157088 a11y: No need to use WeakReference for list children `VCLXAccessibleList` is the owner of the `VCLXAccessibleListItem`s held in that vector, so I see no reason to hold them by weak reference, which according to the doc in `udkapi/com/sun/star/uno/XWeak.idl` is to avoid affecting the lifetime of the objects: > <p>The sense of weak references is to hold a reference to an object > without affecting the lifetime of the object. That means that a weak > reference may become invalid, at any time, if the referenced object dies. > </p> Quite the contrary, it is actually responsible for the lifecycle of the list item a11y objects and should dispose them when itself gets disposed, which will be added in a subsequent commit. Change-Id: I57fe3367f1199cd0c24f006f6e25a1e9c930c154 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156521 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> (cherry picked from commit bfa9d01920e7e042a83627d7fa4e78c70bc7ece5) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156536 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/accessibility/inc/standard/vclxaccessiblelist.hxx b/accessibility/inc/standard/vclxaccessiblelist.hxx index bab8b649fa07..57d43d2c11de 100644 --- a/accessibility/inc/standard/vclxaccessiblelist.hxx +++ b/accessibility/inc/standard/vclxaccessiblelist.hxx @@ -25,7 +25,7 @@ #include <cppuhelper/implbase.hxx> #include <toolkit/awt/vclxaccessiblecomponent.hxx> -typedef std::vector< css::uno::WeakReference< css::accessibility::XAccessible > > +typedef std::vector<css::uno::Reference<css::accessibility::XAccessible>> ListItems; namespace accessibility diff --git a/accessibility/source/standard/vclxaccessiblelist.cxx b/accessibility/source/standard/vclxaccessiblelist.cxx index c38240e3b4e7..57f9b1eabcb3 100644 --- a/accessibility/source/standard/vclxaccessiblelist.cxx +++ b/accessibility/source/standard/vclxaccessiblelist.cxx @@ -107,6 +107,7 @@ void SAL_CALL VCLXAccessibleList::disposing() VCLXAccessibleComponent::disposing(); // Dispose all items in the list. + m_aAccessibleChildren.clear(); m_pListBoxHelper.reset(); @@ -155,14 +156,14 @@ void VCLXAccessibleList::notifyVisibleStates(bool _bSetNew ) // adjust the index inside the VCLXAccessibleListItem for ( ; aIter != m_aAccessibleChildren.end(); ) { - Reference< XAccessible > xHold = *aIter; - if (!xHold.is()) + Reference<XAccessible> xChild = *aIter; + if (!xChild.is()) { aIter = m_aAccessibleChildren.erase(aIter); } else { - VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xHold.get()); + VCLXAccessibleListItem* pItem = static_cast<VCLXAccessibleListItem*>(xChild.get()); const sal_Int32 nTopEntry = m_pListBoxHelper ? m_pListBoxHelper->GetTopEntry() : 0; const sal_Int32 nPos = static_cast<sal_Int32>(aIter - m_aAccessibleChildren.begin()); bool bVisible = ( nPos>=nTopEntry && nPos<( nTopEntry + m_nVisibleLineCount ) ); @@ -205,12 +206,11 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList) { sal_Int32 i=0; m_nCurSelectedPos = LISTBOX_ENTRY_NOTFOUND; - for ( const auto& rChild : m_aAccessibleChildren ) + for (const Reference<XAccessible>& rxChild : m_aAccessibleChildren) { - Reference< XAccessible > xHold = rChild; - if ( xHold.is() ) + if (rxChild.is()) { - VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( xHold.get() ); + VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >(rxChild.get() ); // Retrieve the item's index from the list entry. bool bNowSelected = m_pListBoxHelper->IsEntryPosSelected (i); if (bNowSelected) @@ -218,7 +218,7 @@ void VCLXAccessibleList::UpdateSelection_Impl_Acc(bool bHasDropDownList) if ( bNowSelected && !pItem->IsSelected() ) { - xNewAcc = rChild; + xNewAcc = rxChild; aNewValue <<= xNewAcc; } else if ( pItem->IsSelected() ) @@ -663,12 +663,11 @@ void VCLXAccessibleList::UpdateSelection_Impl(sal_Int32) { sal_Int32 i=0; m_nCurSelectedPos = LISTBOX_ENTRY_NOTFOUND; - for ( const auto& rChild : m_aAccessibleChildren ) + for (const Reference<XAccessible>& rxChild : m_aAccessibleChildren ) { - Reference< XAccessible > xHold = rChild; - if ( xHold.is() ) + if (rxChild.is()) { - VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( xHold.get() ); + VCLXAccessibleListItem* pItem = static_cast< VCLXAccessibleListItem* >( rxChild.get() ); // Retrieve the item's index from the list entry. bool bNowSelected = m_pListBoxHelper->IsEntryPosSelected (i); if (bNowSelected) @@ -676,7 +675,7 @@ void VCLXAccessibleList::UpdateSelection_Impl(sal_Int32) if ( bNowSelected && !pItem->IsSelected() ) { - xNewAcc = rChild; + xNewAcc = rxChild; aNewValue <<= xNewAcc; } else if ( pItem->IsSelected() )