tdf#138108 terminate on uncaught exception in a11y callback

 #1  0x00007ffff5d3fafe in accessibility::AccessibleContextBase::ThrowIfDisposed() (this=0x85de440) at editeng/source/accessibility/AccessibleContextBase.cxx:513
 #2  0x00007ffff5d3fbee in accessibility::AccessibleContextBase::getAccessibleParent() (this=0x85de440) at editeng/source/accessibility/AccessibleContextBase.cxx:203
 #3  0x00007fff999cad24 in SwAccessibleMap::DoInvalidateShapeSelection(bool) (this=0x687e610, bInvalidateFocusMode=false) at sw/source/core/access/accmap.cxx:1647
 #4  0x00007fff999cc5a5 in SwAccessibleMap::InvalidateShapeSelection() (this=0x687e610) at sw/source/core/access/accmap.cxx:1152
 #5  0x00007fff999d78b0 in SwAccessibleMap::InvalidateCursorPosition(SwFrame const*) (this=0x687e610, pFrame=0x5a3faa0) at sw/source/core/access/accmap.cxx:2744
 #6  0x00007fff9aae5c32 in SwViewShellImp::InvalidateAccessibleCursorPosition(SwFrame const*) (this=0x6594330, pFrame=0x5a3faa0) at sw/source/core/view/viewimp.cxx:345
 #7  0x00007fff99b01fcd in SwCursorShell::UpdateCursor(unsigned short, bool) (this=0x6594840, eFlags=7, bIdleEnd=false) at sw/source/core/crsr/crsrsh.cxx:2020
 #8  0x00007fff99b02db4 in SwCursorShell::EndAction(bool, bool) (this=0x6594840, bIdleEnd=false, DoSetPosX=false) at sw/source/core/crsr/crsrsh.cxx:279
 #9  0x00007fff9a2249b2 in SwFEShell::SelectObj(Point const&, unsigned char, SdrObject*) (this=0x6594840, rPt=Point = {...}, nFlag=0 '\000', pObj=0x0)
     at sw/source/core/frmedt/feshview.cxx:323
 #10 0x00007fff9b30eacb in SwWrtShell::UnSelectFrame() (this=0x6594840) at sw/source/uibase/wrtsh/select.cxx:326

Change-Id: I122d087b67c3615afb0c34aa714bc1066946c8c1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106139
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
Tested-by: Jenkins
diff --git a/include/editeng/AccessibleContextBase.hxx b/include/editeng/AccessibleContextBase.hxx
index 9c5027f..183c097 100644
--- a/include/editeng/AccessibleContextBase.hxx
+++ b/include/editeng/AccessibleContextBase.hxx
@@ -250,6 +250,14 @@ public:
    virtual css::uno::Sequence<sal_Int8> SAL_CALL
        getImplementationId() override;

    /** Check whether or not the object has been disposed (or is in the
        state of being disposed).

        @return TRUE, if the object is disposed or in the course
        of being disposed. Otherwise, FALSE is returned.
    */
    bool IsDisposed() const;

protected:
    /** The state set.
    */
@@ -282,14 +290,6 @@ protected:
    */
    void ThrowIfDisposed();

    /** Check whether or not the object has been disposed (or is in the
        state of being disposed).

        @return TRUE, if the object is disposed or in the course
        of being disposed. Otherwise, FALSE is returned.
    */
    bool IsDisposed() const;

    /** sets the role as returned by XaccessibleContext::getAccessibleRole

        <p>Caution: This is only to be used in the construction phase (means within
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index fe2c2e1..dd63845 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -1642,7 +1642,7 @@ void SwAccessibleMap::DoInvalidateShapeSelection(bool bInvalidateFocusMode /*=fa
    for (const auto& rpShape : vecxShapeRemove)
    {
        ::accessibility::AccessibleShape *pAccShape = rpShape.get();
        if (pAccShape)
        if (pAccShape && !pAccShape->IsDisposed())
        {
            uno::Reference< XAccessible > xPara = pAccShape->getAccessibleParent();
            uno::Reference< XAccessibleContext > xParaContext = xPara->getAccessibleContext();