comphelper/source/misc/accessibleeventnotifier.cxx |   31 ++++-----------------
 1 file changed, 7 insertions(+), 24 deletions(-)

New commits:
commit 2dc240a82646fc23c673a6fd5a29ade934dd5b67
Author:     Noel Grandin <[email protected]>
AuthorDate: Tue May 2 14:47:43 2023 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Tue May 2 18:58:18 2023 +0200

    improve AccessibleEventNotifier::addEvent
    
    we use the OInterfaceContainerHelper4 notifyEach function to avoid
    copying a vector of listeners
    
    Change-Id: I96476bb6100630a5c5d0f5d0973f821de702db39
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151290
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/comphelper/source/misc/accessibleeventnotifier.cxx 
b/comphelper/source/misc/accessibleeventnotifier.cxx
index ad9edf574a9f..d146d11812ba 100644
--- a/comphelper/source/misc/accessibleeventnotifier.cxx
+++ b/comphelper/source/misc/accessibleeventnotifier.cxx
@@ -238,33 +238,16 @@ sal_Int32 AccessibleEventNotifier::removeEventListener(
 
 void AccessibleEventNotifier::addEvent( const TClientId _nClient, const 
AccessibleEventObject& _rEvent )
 {
-    std::vector< Reference< XAccessibleEventListener > > aListeners;
-
-    {
-        std::unique_lock aGuard( GetLocalMutex() );
+    std::unique_lock aGuard( GetLocalMutex() );
 
-        ClientMap::iterator aClientPos;
-        if ( !implLookupClient( _nClient, aClientPos ) )
-            // already asserted in implLookupClient
-            return;
+    ClientMap::iterator aClientPos;
+    if ( !implLookupClient( _nClient, aClientPos ) )
+        // already asserted in implLookupClient
+        return;
 
-        // since we're synchronous, again, we want to notify immediately
-        aListeners = aClientPos->second.getElements(aGuard);
-    }
+    // since we're synchronous, again, we want to notify immediately
+    aClientPos->second.notifyEach(aGuard, 
&XAccessibleEventListener::notifyEvent, _rEvent);
 
-    // default handling: loop through all listeners, and notify them
-    for ( const auto& rListener : aListeners )
-    {
-        try
-        {
-            rListener->notifyEvent( _rEvent );
-        }
-        catch( const Exception& )
-        {
-            // no assertion, because a broken access remote bridge or 
something like this
-            // can cause this exception
-        }
-    }
 }
 
 } // namespace comphelper

Reply via email to