thumbnailview a11y: Dispose ThumbnailViewItemAcc objects

This is the ThumbnailViewItemAcc variant of

    commit b3c460980c34d2d9f91120823bb525ece7bc2fac
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Tue Feb 25 12:33:21 2025 +0100

        valueset a11y: Dispose ValueItemAcc objects

and fixes the problem/assert described in

    Change-Id: Ie4e5c300ff6bdb160e756e7173c45c0f143fac69
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Wed Feb 26 11:14:04 2025 +0100

        thumbnailview a11y: Use OAccessibleComponentHelper for ThumbnailViewItemAcc

in the same way as the above-mentioned commit
b3c460980c34d2d9f91120823bb525ece7bc2fac fixed it
for the corresponding ValueItemAcc issue mentioned in
its commit message.

Change-Id: Id2ec7a3bd6311ea63f718f5136f68f2ea94be5f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182226
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
Michael Weghorn 2025-02-26 11:25:49 +01:00
parent 1c3d0bc25f
commit 299f205898
3 changed files with 9 additions and 7 deletions

View File

@ -110,7 +110,7 @@ public:
void setTitle (const OUString& rTitle);
rtl::Reference<ThumbnailViewItemAcc> const & GetAccessible();
rtl::Reference<ThumbnailViewItemAcc> const & GetAccessible(bool bCreate = true);
void setDrawArea (const tools::Rectangle &area);

View File

@ -165,12 +165,12 @@ ThumbnailView::ThumbnailView(std::unique_ptr<weld::ScrolledWindow> xWindow, std:
ThumbnailView::~ThumbnailView()
{
ImplDeleteItems();
if (mxAccessible.is())
mxAccessible->dispose();
mpItemAttrs.reset();
ImplDeleteItems();
}
bool ThumbnailView::MouseMove(const MouseEvent& rMEvt)
@ -290,12 +290,14 @@ void ThumbnailView::ImplDeleteItems()
// fire accessible event???
}
if ( pItem->isVisible() && ImplHasAccessibleListeners() )
rtl::Reference<ThumbnailViewItemAcc> xItemAcc = pItem->GetAccessible(false);
if (xItemAcc.is())
{
css::uno::Any aOldAny, aNewAny;
aOldAny <<= css::uno::Reference<css::accessibility::XAccessible>(pItem->GetAccessible());
ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny );
xItemAcc->dispose();
}
mItemList[i].reset();

View File

@ -111,9 +111,9 @@ void ThumbnailViewItem::setTitle (const OUString& rTitle)
maTitle = rTitle;
}
const rtl::Reference< ThumbnailViewItemAcc > & ThumbnailViewItem::GetAccessible()
const rtl::Reference<ThumbnailViewItemAcc>& ThumbnailViewItem::GetAccessible(bool bCreate)
{
if( !mxAcc.is() )
if (!mxAcc.is() && bCreate)
mxAcc = new ThumbnailViewItemAcc(this);
return mxAcc;