summaryrefslogtreecommitdiff
path: root/sc/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-22 15:02:47 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-22 17:26:09 +0200
commit4e4de8935f38b781374ca34408bd3c57c3cdb69f (patch)
tree94a8c5bd961731b6e0e8db7f80f155a926745c07 /sc/source
parentc5ff4cbd0192773c6503d54325de01abda7e9fa5 (diff)
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 <caolanm@redhat.com>
Diffstat (limited to 'sc/source')
-rw-r--r--sc/source/ui/Accessibility/AccessibleDocument.cxx29
1 files changed, 16 insertions, 13 deletions
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;