From 299f205898f102034a3d3800b5ad726f4e6bb354 Mon Sep 17 00:00:00 2001 From: Michael Weghorn Date: Wed, 26 Feb 2025 11:25:49 +0100 Subject: [PATCH] thumbnailview a11y: Dispose ThumbnailViewItemAcc objects This is the ThumbnailViewItemAcc variant of commit b3c460980c34d2d9f91120823bb525ece7bc2fac Author: Michael Weghorn 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 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 --- include/sfx2/thumbnailviewitem.hxx | 2 +- sfx2/source/control/thumbnailview.cxx | 10 ++++++---- sfx2/source/control/thumbnailviewitem.cxx | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/sfx2/thumbnailviewitem.hxx b/include/sfx2/thumbnailviewitem.hxx index 7d4897482d81..834955082c0d 100644 --- a/include/sfx2/thumbnailviewitem.hxx +++ b/include/sfx2/thumbnailviewitem.hxx @@ -110,7 +110,7 @@ public: void setTitle (const OUString& rTitle); - rtl::Reference const & GetAccessible(); + rtl::Reference const & GetAccessible(bool bCreate = true); void setDrawArea (const tools::Rectangle &area); diff --git a/sfx2/source/control/thumbnailview.cxx b/sfx2/source/control/thumbnailview.cxx index 488264fccdbc..3bcbfb648568 100644 --- a/sfx2/source/control/thumbnailview.cxx +++ b/sfx2/source/control/thumbnailview.cxx @@ -165,12 +165,12 @@ ThumbnailView::ThumbnailView(std::unique_ptr 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 xItemAcc = pItem->GetAccessible(false); + if (xItemAcc.is()) { css::uno::Any aOldAny, aNewAny; - aOldAny <<= css::uno::Reference(pItem->GetAccessible()); ImplFireAccessibleEvent( css::accessibility::AccessibleEventId::CHILD, aOldAny, aNewAny ); + + xItemAcc->dispose(); } mItemList[i].reset(); diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx index 9827b2a62669..8deaa8897df5 100644 --- a/sfx2/source/control/thumbnailviewitem.cxx +++ b/sfx2/source/control/thumbnailviewitem.cxx @@ -111,9 +111,9 @@ void ThumbnailViewItem::setTitle (const OUString& rTitle) maTitle = rTitle; } -const rtl::Reference< ThumbnailViewItemAcc > & ThumbnailViewItem::GetAccessible() +const rtl::Reference& ThumbnailViewItem::GetAccessible(bool bCreate) { - if( !mxAcc.is() ) + if (!mxAcc.is() && bCreate) mxAcc = new ThumbnailViewItemAcc(this); return mxAcc;