diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-02 14:47:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-05-02 18:58:18 +0200 |
commit | 2dc240a82646fc23c673a6fd5a29ade934dd5b67 (patch) | |
tree | 3bec2624571269145095330f7aa1d55e0da7cbbb /comphelper | |
parent | 6e63866ea343dea0d1c528c9f7069be44bc034c0 (diff) |
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/accessibleeventnotifier.cxx | 31 |
1 files changed, 7 insertions, 24 deletions
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 |