summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2018-04-08 09:58:11 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-04-08 15:26:22 +0200
commit1e80227ff76896a2bb6243acff19a49567bb2387 (patch)
tree9c6ab7799fc274c60d75048e547fd4b3fb5a4203
parent49c0d98cb2bec7d171f9847b1335874c05042187 (diff)
Calls to statusChanged may call addStatusListener or removeStatusListener so copy m_aStatusListenerVector on stack and iterate on the copy Thank you Michael for having pointed these Change-Id: I8399db84874d7f68e24c57891a9ab408e7ebef78 Reviewed-on: https://gerrit.libreoffice.org/52579 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> (cherry picked from commit 8fced3ec9ff6f55a6e0b939183cf33b6c3c4a1db) Reviewed-on: https://gerrit.libreoffice.org/52584 Reviewed-by: Michael Stahl <Michael.Stahl@cib.de>
-rw-r--r--sw/source/uibase/uno/unodispatch.cxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx
index fb6c66b38442..acb2496b4b81 100644
--- a/sw/source/uibase/uno/unodispatch.cxx
+++ b/sw/source/uibase/uno/unodispatch.cxx
@@ -257,7 +257,10 @@ void SwXDispatch::dispatch(const util::URL& aURL,
aEvent.State <<= aDescriptor.createPropertyValueSequence();
aEvent.IsEnabled = !rData.sDataSource.isEmpty();
- for ( auto & status : m_aStatusListenerVector )
+ // calls to statusChanged may call addStatusListener or removeStatusListener
+ // so copy m_aStatusListenerVector on stack
+ auto copyStatusListenerVector = m_aStatusListenerVector;
+ for (auto & status : copyStatusListenerVector)
{
if(status.aURL.Complete == cURLDocumentDataSource)
{
@@ -348,7 +351,10 @@ void SwXDispatch::selectionChanged( const lang::EventObject& )
aEvent.IsEnabled = bEnable;
aEvent.Source = *static_cast<cppu::OWeakObject*>(this);
- for ( auto & status : m_aStatusListenerVector )
+ // calls to statusChanged may call addStatusListener or removeStatusListener
+ // so copy m_aStatusListenerVector on stack
+ auto copyStatusListenerVector = m_aStatusListenerVector;
+ for (auto & status : copyStatusListenerVector)
{
aEvent.FeatureURL = status.aURL;
if (status.aURL.Complete != cURLDocumentDataSource)
@@ -367,7 +373,10 @@ void SwXDispatch::disposing( const lang::EventObject& rSource )
lang::EventObject aObject;
aObject.Source = static_cast<cppu::OWeakObject*>(this);
- for ( auto & status : m_aStatusListenerVector )
+ // calls to statusChanged may call addStatusListener or removeStatusListener
+ // so copy m_aStatusListenerVector on stack
+ auto copyStatusListenerVector = m_aStatusListenerVector;
+ for (auto & status : copyStatusListenerVector)
{
status.xListener->disposing(aObject);
}