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;