include/comphelper/interfacecontainer3.hxx | 4 ++++ include/comphelper/interfacecontainer4.hxx | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
New commits: commit 788f2f0bea3d9feb83e9ffcded046c41bc41a0fa Author: Caolán McNamara <[email protected]> AuthorDate: Mon Jan 15 20:02:01 2024 +0000 Commit: Xisco Fauli <[email protected]> CommitDate: Fri Feb 9 14:03:40 2024 +0100 crashtesting: still seeing occasional impl_notifyEvent_nothrow failures e.g.: #0 0x00007f5a3a5d45fc in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent>::operator()(com::sun::star::uno::Reference<com::sun::star::document::XDocumentEventListener> const&) const (this=this@entry=0x7f5a38ffd680, listener=empty uno::Reference) at include/comphelper/interfacecontainer3.hxx:253 #1 0x00007f5a3a5d9427 in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::forEach<comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent> >(comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::NotifySingleListener<com::sun::star::document::DocumentEvent> const&) (this=this@entry=0x7f5a3035ea08, func=...) at include/comphelper/interfacecontainer3.hxx:275 xListener = empty uno::Reference iter = {rCont = @0x7f5a3035ea08, maData = {m_pimpl = 0x7f5a30132260}, nRemain = 1} #2 0x00007f5a3a5d950e in comphelper::OInterfaceContainerHelper3<com::sun::star::document::XDocumentEventListener>::notifyEach<com::sun::star::document::DocumentEvent>(void (com::sun::star::document::XDocumentEventListener::*)(com::sun::star::document::DocumentEvent const&), com::sun::star::document::DocumentEvent const&) (this=this@entry=0x7f5a3035ea08, NotificationMethod=<optimized out>, Event=...) at include/comphelper/interfacecontainer3.hxx:290 #3 0x00007f5a3a5d39f9 in dbaccess::DocumentEventNotifier_Impl::impl_notifyEvent_nothrow(com::sun::star::document::DocumentEvent const&) (this=this@entry=0x7f5a3035e9c0, _rEvent=...) at dbaccess/source/core/dataaccess/documenteventnotifier.cxx:200 __func__ = "impl_notifyEvent_nothrow" #4 0x00007f5a3a5d3b83 in dbaccess::DocumentEventNotifier_Impl::processEvent(comphelper::AnyEvent const&) (this=this@entry=0x7f5a3035e9c0, _rEvent=...) at dbaccess/source/core/dataaccess/documenteventnotifier.cxx:233 rEventHolder = <optimized out> #5 0x00007f5a57cd95ba in comphelper::AsyncEventNotifierBase::execute() (this=this@entry=0x7f5a3010f670) at comphelper/source/misc/asyncnotification.cxx:139 so lets guard the OInterfaceIteratorHelper3 ctor. might as well use empty() to return early then, and align the OInterfaceIteratorHelper4 case with that. Change-Id: I138841840e032e6524792fb75168ccabc666b34c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162127 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> (cherry picked from commit dd8dad09097225726cbcd878d95d5bd0aacdf042) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163101 Reviewed-by: Xisco Fauli <[email protected]> diff --git a/include/comphelper/interfacecontainer3.hxx b/include/comphelper/interfacecontainer3.hxx index 05a82212c064..be140d32289f 100644 --- a/include/comphelper/interfacecontainer3.hxx +++ b/include/comphelper/interfacecontainer3.hxx @@ -266,7 +266,11 @@ template <class T> template <typename FuncT> inline void OInterfaceContainerHelper3<T>::forEach(FuncT const& func) { + osl::ClearableMutexGuard aGuard(mrMutex); + if (std::as_const(maData)->empty()) + return; OInterfaceIteratorHelper3<T> iter(*this); + aGuard.clear(); while (iter.hasMoreElements()) { auto xListener = iter.next(); diff --git a/include/comphelper/interfacecontainer4.hxx b/include/comphelper/interfacecontainer4.hxx index a8b2bdc85505..e4a41e30675d 100644 --- a/include/comphelper/interfacecontainer4.hxx +++ b/include/comphelper/interfacecontainer4.hxx @@ -288,7 +288,7 @@ inline void OInterfaceContainerHelper4<T>::forEach(std::unique_lock<std::mutex>& FuncT const& func) const { assert(rGuard.owns_lock()); - if (std::as_const(maData)->size() == 0) + if (std::as_const(maData)->empty()) { return; }
