Resolves: tdf#147822 ScUnoListenerEntry container must be std::list
... instead of std::vector to not get invalidated iterators when
the container is resized.
Regression from
commit f8defe59ff75df2b516ee407f1dac22b0ac72a19
CommitDate: Wed Sep 6 22:45:10 2017 +0200
Replace some lists by vectors in unoobj (sc)
which was bad for this case.
Change-Id: I8d3a001242865cadc82b359a3198906d26373a41
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136007
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins
diff --git a/sc/inc/listenercalls.hxx b/sc/inc/listenercalls.hxx
index ff835a0..acb0099 100644
--- a/sc/inc/listenercalls.hxx
+++ b/sc/inc/listenercalls.hxx
@@ -19,7 +19,7 @@
#pragma once
#include <vector>
#include <list>
#include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/EventObject.hpp>
@@ -48,7 +48,9 @@ struct ScUnoListenerEntry
class ScUnoListenerCalls
{
private:
::std::vector<ScUnoListenerEntry> aEntries;
// Must be list, not vector, to not invalidate iterators, see
// ExecuteAndClear() implementation.
::std::list<ScUnoListenerEntry> aEntries;
public:
ScUnoListenerCalls();
diff --git a/sc/source/ui/unoobj/listenercalls.cxx b/sc/source/ui/unoobj/listenercalls.cxx
index 2d9a230..7ff7c7d 100644
--- a/sc/source/ui/unoobj/listenercalls.cxx
+++ b/sc/source/ui/unoobj/listenercalls.cxx
@@ -44,7 +44,7 @@ void ScUnoListenerCalls::ExecuteAndClear()
// During each modified() call, Add may be called again.
// These new calls are executed here, too.
std::vector<ScUnoListenerEntry>::iterator aItr(aEntries.begin());
std::list<ScUnoListenerEntry>::iterator aItr(aEntries.begin());
while (aItr != aEntries.end())
{
ScUnoListenerEntry aEntry = *aItr;