summaryrefslogtreecommitdiff
path: root/comphelper/source/misc/accessibleeventnotifier.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'comphelper/source/misc/accessibleeventnotifier.cxx')
-rw-r--r--comphelper/source/misc/accessibleeventnotifier.cxx65
1 files changed, 27 insertions, 38 deletions
diff --git a/comphelper/source/misc/accessibleeventnotifier.cxx b/comphelper/source/misc/accessibleeventnotifier.cxx
index d2694ab6120b..c1e26c35bdd9 100644
--- a/comphelper/source/misc/accessibleeventnotifier.cxx
+++ b/comphelper/source/misc/accessibleeventnotifier.cxx
@@ -19,7 +19,7 @@
#include <comphelper/accessibleeventnotifier.hxx>
#include <com/sun/star/accessibility/XAccessibleEventListener.hpp>
-#include <comphelper/interfacecontainer2.hxx>
+#include <comphelper/interfacecontainer4.hxx>
#include <map>
#include <memory>
@@ -35,16 +35,16 @@ namespace {
typedef std::pair< AccessibleEventNotifier::TClientId,
AccessibleEventObject > ClientEvent;
-typedef std::map< AccessibleEventNotifier::TClientId,
- ::comphelper::OInterfaceContainerHelper2* > ClientMap;
+typedef ::comphelper::OInterfaceContainerHelper4<XAccessibleEventListener> ListenerContainer;
+typedef std::map< AccessibleEventNotifier::TClientId, ListenerContainer* > ClientMap;
/// key is the end of the interval, value is the start of the interval
typedef std::map<AccessibleEventNotifier::TClientId,
AccessibleEventNotifier::TClientId> IntervalMap;
-::osl::Mutex& GetLocalMutex()
+std::mutex& GetLocalMutex()
{
- static ::osl::Mutex MUTEX;
+ static std::mutex MUTEX;
return MUTEX;
}
@@ -149,19 +149,13 @@ namespace comphelper {
AccessibleEventNotifier::TClientId AccessibleEventNotifier::registerClient()
{
- ::osl::MutexGuard aGuard( GetLocalMutex() );
+ std::scoped_lock aGuard( GetLocalMutex() );
// generate a new client id
TClientId nNewClientId = generateId( );
// the event listeners for the new client
- ::comphelper::OInterfaceContainerHelper2 *const pNewListeners =
- new ::comphelper::OInterfaceContainerHelper2( GetLocalMutex() );
- // note that we're using our own mutex here, so the listener containers for all
- // our clients share this same mutex.
- // this is a reminiscence to the days where the notifier was asynchronous. Today this is
- // completely nonsense, and potentially slowing down the Office me thinks...
-
+ ListenerContainer * pNewListeners = new ListenerContainer();
// add the client
gaClients.emplace( nNewClientId, pNewListeners );
@@ -171,7 +165,7 @@ AccessibleEventNotifier::TClientId AccessibleEventNotifier::registerClient()
void AccessibleEventNotifier::revokeClient( const TClientId _nClient )
{
- ::osl::MutexGuard aGuard( GetLocalMutex() );
+ std::scoped_lock aGuard( GetLocalMutex() );
ClientMap::iterator aClientPos;
if ( !implLookupClient( _nClient, aClientPos ) )
@@ -187,40 +181,35 @@ void AccessibleEventNotifier::revokeClient( const TClientId _nClient )
void AccessibleEventNotifier::revokeClientNotifyDisposing(
const TClientId _nClient, const Reference< XInterface >& _rxEventSource )
{
- std::unique_ptr<::comphelper::OInterfaceContainerHelper2> pListeners;
-
- {
- // rhbz#1001768 drop the mutex before calling disposeAndClear
- ::osl::MutexGuard 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;
- // notify the listeners
- pListeners.reset(aClientPos->second);
+ // notify the listeners
+ std::unique_ptr<ListenerContainer> pListeners(aClientPos->second);
- // we do not need the entry in the clients map anymore
- // (do this before actually notifying, because some client
- // implementations have re-entrance problems and call into
- // revokeClient while we are notifying from here)
- gaClients.erase(aClientPos);
- releaseId(_nClient);
- }
+ // we do not need the entry in the clients map anymore
+ // (do this before actually notifying, because some client
+ // implementations have re-entrance problems and call into
+ // revokeClient while we are notifying from here)
+ gaClients.erase(aClientPos);
+ releaseId(_nClient);
// notify the "disposing" event for this client
EventObject aDisposalEvent;
aDisposalEvent.Source = _rxEventSource;
// now really do the notification
- pListeners->disposeAndClear( aDisposalEvent );
+ pListeners->disposeAndClear( aGuard, aDisposalEvent );
}
sal_Int32 AccessibleEventNotifier::addEventListener(
const TClientId _nClient, const Reference< XAccessibleEventListener >& _rxListener )
{
- ::osl::MutexGuard aGuard( GetLocalMutex() );
+ std::scoped_lock aGuard( GetLocalMutex() );
ClientMap::iterator aClientPos;
if ( !implLookupClient( _nClient, aClientPos ) )
@@ -236,7 +225,7 @@ sal_Int32 AccessibleEventNotifier::addEventListener(
sal_Int32 AccessibleEventNotifier::removeEventListener(
const TClientId _nClient, const Reference< XAccessibleEventListener >& _rxListener )
{
- ::osl::MutexGuard aGuard( GetLocalMutex() );
+ std::scoped_lock aGuard( GetLocalMutex() );
ClientMap::iterator aClientPos;
if ( !implLookupClient( _nClient, aClientPos ) )
@@ -251,10 +240,10 @@ sal_Int32 AccessibleEventNotifier::removeEventListener(
void AccessibleEventNotifier::addEvent( const TClientId _nClient, const AccessibleEventObject& _rEvent )
{
- std::vector< Reference< XInterface > > aListeners;
+ std::vector< Reference< XAccessibleEventListener > > aListeners;
{
- ::osl::MutexGuard aGuard( GetLocalMutex() );
+ std::scoped_lock aGuard( GetLocalMutex() );
ClientMap::iterator aClientPos;
if ( !implLookupClient( _nClient, aClientPos ) )
@@ -270,7 +259,7 @@ void AccessibleEventNotifier::addEvent( const TClientId _nClient, const Accessib
{
try
{
- static_cast< XAccessibleEventListener* >( rListener.get() )->notifyEvent( _rEvent );
+ rListener->notifyEvent( _rEvent );
}
catch( const Exception& )
{