Resolves: tdf#138512 don't crash on removing already Disposed a11y context
Change-Id: I2a8f3d10a1349de233e11d841f7f244e4e513b2c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151523
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx
index 49f7830..57b9610 100644
--- a/sw/source/core/access/acccontext.cxx
+++ b/sw/source/core/access/acccontext.cxx
@@ -518,9 +518,14 @@ bool SwAccessibleContext::IsEditableState()
return bRet;
}
bool SwAccessibleContext::IsDisposed() const
{
return !(GetFrame() && GetMap());
}
void SwAccessibleContext::ThrowIfDisposed()
{
if (!(GetFrame() && GetMap()))
if (IsDisposed())
{
throw lang::DisposedException("object is nonfunctional",
static_cast<cppu::OWeakObject*>(this));
diff --git a/sw/source/core/access/acccontext.hxx b/sw/source/core/access/acccontext.hxx
index 32d13ef..d649390 100644
--- a/sw/source/core/access/acccontext.hxx
+++ b/sw/source/core/access/acccontext.hxx
@@ -349,6 +349,8 @@ public:
virtual bool SetSelectedState(bool bSelected);
bool IsSelectedInDoc() const { return m_isSelectedInDoc; }
bool IsDisposed() const;
static OUString GetResource(TranslateId pResId,
const OUString *pArg1 = nullptr,
const OUString *pArg2 = nullptr);
diff --git a/sw/source/core/access/accmap.cxx b/sw/source/core/access/accmap.cxx
index 2ada9c5..2fc8a76 100644
--- a/sw/source/core/access/accmap.cxx
+++ b/sw/source/core/access/accmap.cxx
@@ -2679,7 +2679,9 @@ void SwAccessibleMap::InvalidateCursorPosition( const SwFrame *pFrame )
for (SwAccessibleParagraph* pAccPara : m_setParaRemove)
{
if(pAccPara && pAccPara->getSelectedAccessibleChildCount() == 0 && pAccPara->getSelectedText().getLength() == 0)
if (pAccPara && !pAccPara->IsDisposed() &&
pAccPara->getSelectedAccessibleChildCount() == 0 &&
pAccPara->getSelectedText().getLength() == 0)
{
if(pAccPara->SetSelectedState(false))
{