sw/source/uibase/uno/unodispatch.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
New commits: commit 1e80227ff76896a2bb6243acff19a49567bb2387 Author: Julien Nabet <serval2...@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 <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 8fced3ec9ff6f55a6e0b939183cf33b6c3c4a1db) Reviewed-on: https://gerrit.libreoffice.org/52584 Reviewed-by: Michael Stahl <michael.st...@cib.de> 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); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits