sc/source/ui/Accessibility/AccessibleDocument.cxx | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-)
New commits: commit 4e4de8935f38b781374ca34408bd3c57c3cdb69f Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Sep 22 15:02:47 2020 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Sep 22 17:26:09 2020 +0200 tdf#121323 avoid assert about duplicate listeners attach the new one after the old one is disposed Change-Id: I0a020aeaa658832c03d18fcfaf341a56b8e65dfc Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103175 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 42b7ee4bcc73..41539ea93faf 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -425,28 +425,31 @@ bool ScChildrenShapes::ReplaceChild (::accessibility::AccessibleShape* pCurrentC ::accessibility::AccessibleShapeInfo ( _rxShape, pCurrentChild->getAccessibleParent(), this ), _rShapeTreeInfo )); - if ( pReplacement.is() ) - pReplacement->Init(); bool bResult(false); if (pReplacement.is()) { OSL_ENSURE(pCurrentChild->GetXShape().get() == pReplacement->GetXShape().get(), "XShape changes and should be inserted sorted"); auto it = maShapesMap.find(pCurrentChild->GetXShape()); - if (it != maShapesMap.end()) + if (it != maShapesMap.end() && it->second->pAccShape.is()) { - if (it->second->pAccShape.is()) - { - OSL_ENSURE(it->second->pAccShape == pCurrentChild, "wrong child found"); - AccessibleEventObject aEvent; - aEvent.EventId = AccessibleEventId::CHILD; - aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); - aEvent.OldValue <<= uno::Reference<XAccessible>(pCurrentChild); + OSL_ENSURE(it->second->pAccShape == pCurrentChild, "wrong child found"); + AccessibleEventObject aEvent; + aEvent.EventId = AccessibleEventId::CHILD; + aEvent.Source = uno::Reference< XAccessibleContext >(mpAccessibleDocument); + aEvent.OldValue <<= uno::Reference<XAccessible>(pCurrentChild); + + mpAccessibleDocument->CommitChange(aEvent); // child is gone - event - mpAccessibleDocument->CommitChange(aEvent); // child is gone - event + pCurrentChild->dispose(); + } - pCurrentChild->dispose(); - } + // Init after above possible pCurrentChild->dispose so we don't trigger the assert + // ScDrawModelBroadcaster::addShapeEventListener of duplicate listeners + pReplacement->Init(); + + if (it != maShapesMap.end()) + { it->second->pAccShape = pReplacement; AccessibleEventObject aEvent; aEvent.EventId = AccessibleEventId::CHILD; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits