sw/source/core/access/acccontext.cxx | 7 ++++++- sw/source/core/access/acccontext.hxx | 2 ++ sw/source/core/access/accmap.cxx | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-)
New commits: commit 594aac44a5e06ef8ecc5ab0b30a3620191a5b936 Author: Caolán McNamara <[email protected]> AuthorDate: Tue May 9 14:16:20 2023 +0100 Commit: Michael Stahl <[email protected]> CommitDate: Wed May 10 11:22:29 2023 +0200 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 <[email protected]> diff --git a/sw/source/core/access/acccontext.cxx b/sw/source/core/access/acccontext.cxx index 49f783075128..57b9610821a4 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 32d13efbf513..d64939089622 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 2ada9c50b8c0..2fc8a76daa90 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)) {
