summaryrefslogtreecommitdiff
path: root/accessibility
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-09-04 17:03:47 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-09-04 21:41:00 +0200
commitbfa9d01920e7e042a83627d7fa4e78c70bc7ece5 (patch)
tree2fc81dd1d6a35c4f858da35de8ce976c9caf93a7 /accessibility
parentb273a0c1527193e21fbd0ccbc23853205f90056b (diff)
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.weghorn@posteo.de>
Diffstat (limited to 'accessibility')
-rw-r--r--accessibility/inc/standard/vclxaccessiblelist.hxx2
-rw-r--r--accessibility/source/standard/vclxaccessiblelist.cxx25
2 files changed, 13 insertions, 14 deletions
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() )