include/comphelper/interfacecontainer4.hxx | 3 +++ sfx2/source/notify/globalevents.cxx | 1 + 2 files changed, 4 insertions(+)
New commits: commit a605f2f8fd3e848ed1229328144f948adea82256 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Tue Jan 18 11:03:55 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Tue Jan 18 15:04:18 2022 +0100 fix locking in comphelper::OInterfaceContainerHelper4::forEach regression from commit a2eaf99e46f370ffb3b73828c2bdc53dc193b9a4 Author: Noel Grandin <noel.gran...@collabora.co.uk> Date: Fri Jan 14 10:56:50 2022 +0200 make comphelper::OInterfaceContainerHelper4 more threadsafe Change-Id: Iea42fd0bba6da99d82076b4d1b495d67fa62243c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128526 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/comphelper/interfacecontainer4.hxx b/include/comphelper/interfacecontainer4.hxx index b8e2079a9201..1df8f47776eb 100644 --- a/include/comphelper/interfacecontainer4.hxx +++ b/include/comphelper/interfacecontainer4.hxx @@ -271,7 +271,10 @@ inline void OInterfaceContainerHelper4<T>::forEach(std::unique_lock<std::mutex>& FuncT const& func) { if (std::as_const(maData)->size() == 0) + { + rGuard.unlock(); // code depends on the guard being unlocked after return return; + } maData.make_unique(); // so we can iterate over the data without holding the lock OInterfaceIteratorHelper4<T> iter(rGuard, *this); rGuard.unlock(); diff --git a/sfx2/source/notify/globalevents.cxx b/sfx2/source/notify/globalevents.cxx index 817e8a38448b..17719f992341 100644 --- a/sfx2/source/notify/globalevents.cxx +++ b/sfx2/source/notify/globalevents.cxx @@ -487,6 +487,7 @@ void SfxGlobalEvents_Impl::implts_notifyListener(const document::DocumentEvent& xListener->notifyEvent(aLegacyEvent); } ); + g.lock(); m_aDocumentListeners.forEach(g, [&aEvent](const css::uno::Reference<document::XDocumentEventListener>& xListener) {