winaccessibility/source/service/AccObjectWinManager.cxx |   10 ++++++++++
 1 file changed, 10 insertions(+)

New commits:
commit 071b626079243908cfa85a5bd49620235fdf48cf
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 11 16:53:05 2024 +0100
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Thu Sep 12 07:07:49 2024 +0200

    tdf#91739 wina11y: Create AccObject for parent as necessary
    
    In `AccObjectWinManager::InsertAccObj`, when no HWND
    was explicitly passed, it is attempted to retrieve the
    HWND from the parent's `AccObject`.
    
    If no parent AccObject exists yet, create/insert that
    one first.
    
    This fixes the following assert seen when using NVDA's SayAll
    feature to read the whole document with sample document mentioned in NVDA
    issue [1], also attached as attachment 196385 in tdf#91739
    for reference:
    
        Assertion failed: pIAccessible && "Couldn't retrieve IAccessible object 
for relation target.", file 
C:/tools/cygwin/home/user/development/git/libreoffice/winaccessibility/source/UAccCOM/MAccessible.cxx,
 line 2755
    
    It's also reproducible when manually trying to get the next
    flows-to relation target via NVDA's Python console when the
    first cell in the table has focus:
    
        >>> focus.flowsTo
    
    The issue is not reproducible when focus had been in the
    second cell before, as an accessible object has already
    been created otherwise in that case.
    
    Backtrace:
    
        1  abort                                   ucrtbase             
0x7fff3b72286e
        2  get_wpgmptr                             ucrtbase             
0x7fff3b7241b5
        3  wassert                                 ucrtbase             
0x7fff3b7244f1
        4  CMAccessible::get_relationTargetsOfType MAccessible.cxx 2755 
0x7fff1e028729
        5  NdrSendReceive                          RPCRT4               
0x7fff3d4ca2d3
        6  NdrStubCall2                            RPCRT4               
0x7fff3d4625a7
        7  CStdStubBuffer_Invoke                   combase              
0x7fff3cfbc4ac
        8  RoGetAgileReference                     combase              
0x7fff3cf669c3
        9  RoGetAgileReference                     combase              
0x7fff3cf6674e
        10 HSTRING_UserSize                        combase              
0x7fff3cfbefb6
        11 DllGetClassObject                       combase              
0x7fff3cf470b3
        12 CoWaitForMultipleHandles                combase              
0x7fff3cf6774d
        13 RoGetActivatableClassRegistration       combase              
0x7fff3cf2eb26
        14 CoGetMarshalSizeMax                     combase              
0x7fff3cf5cfba
        15 CallWindowProcW                         USER32               
0x7fff3ccbef5c
        16 DispatchMessageW                        USER32               
0x7fff3ccbe684
        17 ImplSalDispatchMessage                  salinst.cxx     475  
0x7ffed452d378
        18 ImplSalYield                            salinst.cxx     552  
0x7ffed452da9d
        19 WinSalInstance::DoYield                 salinst.cxx     581  
0x7ffed452cfa1
        20 ImplYield                               svapp.cxx       385  
0x7ffed78befc4
        21 Application::Yield                      svapp.cxx       474  
0x7ffed78c2cd2
        22 Application::Execute                    svapp.cxx       361  
0x7ffed78bc656
        23 desktop::Desktop::Main                  app.cxx         1691 
0x7ffeecf689b7
        24 ImplSVMain                              svmain.cxx      228  
0x7ffed78d3d4c
        25 SVMain                                  svmain.cxx      261  
0x7ffed78d45a2
        26 soffice_main                            sofficemain.cxx 121  
0x7ffeecfb9064
        27 sal_main                                main.c          51   
0x7ff782681013
        28 main                                    main.c          49   
0x7ff78268105a
        29 __scrt_common_main_seh                  exe_common.inl  288  
0x7ff782681344
        30 BaseThreadInitThunk                     KERNEL32             
0x7fff3bb07374
        31 RtlUserThreadStart                      ntdll                
0x7fff3d85cc91
    
    [1] https://github.com/nvaccess/nvda/issues/8152#issuecomment-2342167620
    
    Change-Id: I246251f06d1885e0da96600ffc7dd0549854382f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173224
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>
    Tested-by: Jenkins

diff --git a/winaccessibility/source/service/AccObjectWinManager.cxx 
b/winaccessibility/source/service/AccObjectWinManager.cxx
index 62bd5f2a27eb..c6edbb0b0392 100644
--- a/winaccessibility/source/service/AccObjectWinManager.cxx
+++ b/winaccessibility/source/service/AccObjectWinManager.cxx
@@ -615,6 +615,16 @@ bool AccObjectWinManager::InsertAccObj( XAccessible* 
pXAcc,XAccessible* pParentX
         if(pParentXAcc)
         {
             AccObject* pObj = GetAccObjByXAcc(pParentXAcc);
+
+            // insert parent if necessary
+            if (!pObj)
+            {
+                Reference<XAccessibleContext> xParentContext = 
pParentXAcc->getAccessibleContext();
+                assert(xParentContext.is() && "parent accessible has no 
context");
+                InsertAccObj(pParentXAcc, 
xParentContext->getAccessibleParent().get());
+                pObj = GetAccObjByXAcc(pParentXAcc);
+            }
+
             if(pObj)
                 pWnd = pObj->GetParentHWND();
         }

Reply via email to