diff options
author | Noel Grandin <noel@peralex.com> | 2018-10-05 09:37:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-05 13:32:37 +0200 |
commit | a20ec3b5cd691ae18f0d87d045673ce3a06579c6 (patch) | |
tree | 38ddc91beef33a9dd623ff13c65faff9d04f7dbf /svl/source/notify/broadcast.cxx | |
parent | cb2f30897ca5d9ced5b4a4d801af6f0a22c98cc0 (diff) |
fix iterator invalidation assert
which only recent versions of MSVC (from 15.8.6) seem to spot.
It resulted in PythonTest_sw_python failures with "vector
iterators incompatible" assertion on the
dest != maDestructedListeners.end()
check
ever since
commit 4a290888580474f9542f185091bb2a6fcf4e9a53
Date: Mon Oct 1 14:31:00 2018 +0200
SvtBroadcaster unify the normal and PrepareForDestruction paths
Although this code appears to always have been wrong, it is just
that it is being hit much more often now.
Change-Id: I45d4f2ceef4ddf19c205702645a41363eea93f21
Reviewed-on: https://gerrit.libreoffice.org/61397
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl/source/notify/broadcast.cxx')
-rw-r--r-- | svl/source/notify/broadcast.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/svl/source/notify/broadcast.cxx b/svl/source/notify/broadcast.cxx index 7e67de0bcdf1..bef049a84c5c 100644 --- a/svl/source/notify/broadcast.cxx +++ b/svl/source/notify/broadcast.cxx @@ -94,15 +94,16 @@ SvtBroadcaster::~SvtBroadcaster() Normalize(); { + auto dest(maDestructedListeners.data()); SfxHint aHint(SfxHintId::Dying); - ListenersType::const_iterator dest(maDestructedListeners.begin()); for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it) { + auto destEnd(dest + maDestructedListeners.size()); // skip the destructed ones - while (dest != maDestructedListeners.end() && (*dest < *it)) + while (dest != destEnd && (*dest < *it)) ++dest; - if (dest == maDestructedListeners.end() || *dest != *it) + if (dest == destEnd || *dest != *it) (*it)->Notify(aHint); } } @@ -113,14 +114,15 @@ SvtBroadcaster::~SvtBroadcaster() // listeners, with the exception of those that already asked to be removed // during their own destruction { - ListenersType::const_iterator dest(maDestructedListeners.begin()); + auto dest(maDestructedListeners.data()); for (ListenersType::iterator it(maListeners.begin()); it != maListeners.end(); ++it) { + auto destEnd(dest + maDestructedListeners.size()); // skip the destructed ones - while (dest != maDestructedListeners.end() && (*dest < *it)) + while (dest != destEnd && (*dest < *it)) ++dest; - if (dest == maDestructedListeners.end() || *dest != *it) + if (dest == destEnd || *dest != *it) (*it)->BroadcasterDying(*this); } } |