accessibility/source/standard/vclxaccessibletoolbox.cxx |   11 ++++++++---
 vcl/source/window/accessibility.cxx                     |    2 +-
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit ade99ebb4d00f58339c86bcf4c952805ddce922b
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Tue Mar 5 19:21:21 2024 +0100
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Thu Mar 7 10:58:11 2024 +0100

    vcl,accessibility: try to fix a crash while disposing SvxFontNameBox_Impl
    
    This happened in a 6.3 based branch, no idea how to reproduce it.
    Clearly the SvxFontNameBox_Impl is being disposed and in its base class
    Window::dispose() when a call to SvxFontNameBox_Impl::CreateAccessible()
    happens, which seems very suspicious; try to prevent that.
    
    mergedlo.dll!ImplListBox::InsertEntry(long nPos, const rtl::OUString & 
rStr) Zeile 2225
            unter d:\lo    mergedlo.dll!ComboBox::InsertEntry(const 
rtl::OUString & rStr, long nPos) Zeile 886
            unter d:\lo    mergedlo.dll!FontNameBox::Fill(const FontList * 
pList) Zeile 447
            unter d:\lo    [Inlineframe] 
mergedlo.dll!SvxFontNameBox_Impl::Fill(const FontList * pList) Zeile 236
            unter d:\lo    mergedlo.dll!lcl_GetDocFontList(const FontList * * 
ppFontList, SvxFontNameBox_Impl * pBox) Zeile 1290
            unter d:\lo    mergedlo.dll!SvxFontNameBox_Impl::FillList() Zeile 
1331
            unter d:\lo    mergedlo.dll!SvxFontNameBox_Impl::CreateAccessible() 
Zeile 3739
            unter d:\lo    mergedlo.dll!vcl::Window::GetAccessible(bool 
bCreate) Zeile 129
            unter d:\lo    
acclo.dll!VCLXAccessibleToolBox::getAccessibleChild(long i) Zeile 733
            unter d:\lo    
acclo.dll!VCLXAccessibleToolBox::GetItemWindowAccessible(const VclWindowEvent & 
rVclWindowEvent) Zeile 784
            unter d:\lo    
acclo.dll!VCLXAccessibleToolBox::GetChildAccessible(const VclWindowEvent & 
rVclWindowEvent) Zeile 795
            unter d:\lo    
mergedlo.dll!VCLXAccessibleComponent::ProcessWindowChildEvent(const 
VclWindowEvent & rVclWindowEvent) Zeile 165
            unter d:\lo    
acclo.dll!VCLXAccessibleToolBox::ProcessWindowChildEvent(const VclWindowEvent & 
rVclWindowEvent) Zeile 657
            unter d:\lo    
mergedlo.dll!VCLXAccessibleComponent::WindowChildEventListener(VclWindowEvent & 
rEvent) Zeile 129
            unter d:\lo    
mergedlo.dll!VCLXAccessibleComponent::LinkStubWindowChildEventListener(void * 
instance, VclWindowEvent & data) Zeile 118
            unter d:\lo    [Inlineframe] mergedlo.dll!Link<VclWindowEvent 
&,void>::Call(VclWindowEvent &) Zeile 84
            unter d:\lo    
mergedlo.dll!vcl::Window::CallEventListeners(VclEventId nEvent, void * pData) 
Zeile 280
            unter d:\lo    mergedlo.dll!vcl::Window::ImplResetReallyVisible() 
Zeile 735
            unter d:\lo    mergedlo.dll!vcl::Window::ImplResetReallyVisible() 
Zeile 747
            unter d:\lo    mergedlo.dll!vcl::Window::Show(bool bVisible, 
ShowFlags nFlags) Zeile 2198
            unter d:\lo    mergedlo.dll!vcl::Window::Show(bool bVisible, 
ShowFlags nFlags) Zeile 2176
            unter d:\lo    [Inlineframe] mergedlo.dll!vcl::Window::Hide() Zeile 
925
            unter d:\lo    mergedlo.dll!vcl::Window::dispose() Zeile 402
            unter d:\lo    mergedlo.dll!Edit::dispose() Zeile 258
            unter d:\lo    mergedlo.dll!ComboBox::dispose() Zeile 132
            unter d:\lo    mergedlo.dll!SvxFontNameBox_Impl::dispose() Zeile 
1322
            unter d:\lo    [Inlineframe] 
mergedlo.dll!VclPtr<SvxFontNameBox_Impl>::disposeAndClear() Zeile 206
            unter d:\lo    mergedlo.dll!SvxFontNameToolBoxControl::dispose() 
Zeile 3309
            unter d:\lo    
mergedlo.dll!framework::ToolBarManager::RemoveControllers() Zeile 651
            unter d:\lo    mergedlo.dll!framework::ToolBarManager::dispose() 
Zeile 468
            unter d:\lo    mergedlo.dll!framework::ToolBarWrapper::dispose() 
Zeile 105
            unter d:\lo    
mergedlo.dll!framework::ToolbarLayoutManager::destroyToolbars() Zeile 666
            unter d:\lo    
mergedlo.dll!framework::ToolbarLayoutManager::reset() Zeile 364
            unter d:\lo    
mergedlo.dll!framework::LayoutManager::implts_reset(bool bAttached) Zeile 458
            unter d:\lo    
mergedlo.dll!framework::LayoutManager::frameAction(const 
com::sun::star::frame::FrameActionEvent & aEvent) Zeile 2757
            unter d:\lo    mergedlo.dll!`anonymous 
namespace'::XFrameImpl::implts_sendFrameActionEvent(const 
com::sun::star::frame::FrameAction & aAction) Zeile 2952
            unter d:\lo    mergedlo.dll!`anonymous 
namespace'::XFrameImpl::setComponent(const 
com::sun::star::uno::Reference<com::sun::star::awt::XWindow> & 
xComponentWindow, const 
com::sun::star::uno::Reference<com::sun::star::frame::XController> & 
xController) Zeile 1470
            unter d:\lo    mergedlo.dll!`anonymous 
namespace'::XFrameImpl::close(unsigned char bDeliverOwnership) Zeile 1701
            unter d:\lo    
mergedlo.dll!framework::pattern::frame::closeIt(const 
com::sun::star::uno::Reference<com::sun::star::uno::XInterface> & xResource) 
Zeile 62
            unter d:\lo    [Inlineframe] 
mergedlo.dll!framework::CloseDispatcher::implts_closeFrame() Zeile 492
            unter d:\lo    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164451
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>
    (cherry picked from commit 825dde03999a55d02e4d5bc88a4d5beacb65e67f)
    
    Change-Id: Ie05cd05158df58021d0fb4a19e9e38cd35af2426

diff --git a/accessibility/source/standard/vclxaccessibletoolbox.cxx 
b/accessibility/source/standard/vclxaccessibletoolbox.cxx
index 5f5089ab5dbb..1a733a6eeb4f 100644
--- a/accessibility/source/standard/vclxaccessibletoolbox.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolbox.cxx
@@ -730,9 +730,14 @@ Reference< XAccessible > SAL_CALL 
VCLXAccessibleToolBox::getAccessibleChild( sal
         Reference< XAccessible> xParent = pChild;
         if ( pItemWindow )
         {
-            xChild = new 
OToolBoxWindowItem(0,::comphelper::getProcessComponentContext(),pItemWindow->GetAccessible(),xParent);
-            pItemWindow->SetAccessible(xChild);
-            pChild->SetChild( xChild );
+            auto const xInnerAcc(pItemWindow->GetAccessible());
+            if (xInnerAcc) // else child is being disposed - avoid crashing
+            {
+                xChild = new OToolBoxWindowItem(0,
+                    ::comphelper::getProcessComponentContext(), xInnerAcc, 
xParent);
+                pItemWindow->SetAccessible(xChild);
+                pChild->SetChild( xChild );
+            }
         }
         xChild = pChild;
         if ( nHighlightItemId > 0 && nItemId == nHighlightItemId )
diff --git a/vcl/source/window/accessibility.cxx 
b/vcl/source/window/accessibility.cxx
index ef3bf456e7a9..58a2028aa1aa 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -125,7 +125,7 @@ css::uno::Reference< css::accessibility::XAccessible > 
Window::GetAccessible( bo
     */
     if ( !mpWindowImpl )
         return css::uno::Reference< css::accessibility::XAccessible >();
-    if ( !mpWindowImpl->mxAccessible.is() && bCreate )
+    if (!mpWindowImpl->mxAccessible.is() && !mpWindowImpl->mbInDispose && 
bCreate)
         mpWindowImpl->mxAccessible = CreateAccessible();
 
     return mpWindowImpl->mxAccessible;

Reply via email to