[Libreoffice-commits] core.git: sw/source

Julien Nabet serval2412 at yahoo.fr
Sun Apr 8 09:59:17 UTC 2018


 sw/source/uibase/uno/unodispatch.cxx |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

New commits:
commit 8fced3ec9ff6f55a6e0b939183cf33b6c3c4a1db
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Sun Apr 8 09:58:11 2018 +0200

    Fix regressions from d727476cff29382a34103b137542e15e1aeeb4b9
    
    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 at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/uibase/uno/unodispatch.cxx b/sw/source/uibase/uno/unodispatch.cxx
index f8b496109581..0f3b7b170b05 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);
     }


More information about the Libreoffice-commits mailing list