diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-18 11:03:55 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-18 15:04:18 +0100 |
commit | a605f2f8fd3e848ed1229328144f948adea82256 (patch) | |
tree | 5233ff88c51aa74be16b1d0ecf19dee8b6e2dab7 | |
parent | 1103240cb3e884ea6024a690eeed743934662a12 (diff) |
fix locking in comphelper::OInterfaceContainerHelper4::forEach
regression from
commit a2eaf99e46f370ffb3b73828c2bdc53dc193b9a4
Author: Noel Grandin <noel.grandin@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.grandin@collabora.co.uk>
-rw-r--r-- | include/comphelper/interfacecontainer4.hxx | 3 | ||||
-rw-r--r-- | sfx2/source/notify/globalevents.cxx | 1 |
2 files changed, 4 insertions, 0 deletions
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) { |