From 48de5010d88454e886aa8b280ae51a6ee884b870 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Thu, 16 Jun 2022 21:44:40 +0200 Subject: 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 Tested-by: Jenkins (cherry picked from commit 7a0a0e23b7e81c1ee0601824a4ee990a2178f98b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136023 Reviewed-by: Xisco Fauli --- sc/inc/listenercalls.hxx | 6 ++++-- sc/source/ui/unoobj/listenercalls.cxx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sc/inc/listenercalls.hxx b/sc/inc/listenercalls.hxx index ff835a048b1a..acb009937fa1 100644 --- a/sc/inc/listenercalls.hxx +++ b/sc/inc/listenercalls.hxx @@ -19,7 +19,7 @@ #pragma once -#include +#include #include #include @@ -48,7 +48,9 @@ struct ScUnoListenerEntry class ScUnoListenerCalls { private: - ::std::vector aEntries; + // Must be list, not vector, to not invalidate iterators, see + // ExecuteAndClear() implementation. + ::std::list aEntries; public: ScUnoListenerCalls(); diff --git a/sc/source/ui/unoobj/listenercalls.cxx b/sc/source/ui/unoobj/listenercalls.cxx index 2d9a23083ca8..7ff7c7df0956 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::iterator aItr(aEntries.begin()); + std::list::iterator aItr(aEntries.begin()); while (aItr != aEntries.end()) { ScUnoListenerEntry aEntry = *aItr; -- cgit