diff options
Diffstat (limited to 'chart2/source/controller/main/CommandDispatch.cxx')
-rw-r--r-- | chart2/source/controller/main/CommandDispatch.cxx | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/chart2/source/controller/main/CommandDispatch.cxx b/chart2/source/controller/main/CommandDispatch.cxx index ed6370a5228b..2cb25f68d5bf 100644 --- a/chart2/source/controller/main/CommandDispatch.cxx +++ b/chart2/source/controller/main/CommandDispatch.cxx @@ -19,7 +19,6 @@ #include "CommandDispatch.hxx" #include <com/sun/star/util/URLTransformer.hpp> -#include <tools/diagnose_ex.h> using namespace ::com::sun::star; @@ -31,7 +30,6 @@ namespace chart CommandDispatch::CommandDispatch( const Reference< uno::XComponentContext > & xContext ) : - impl::CommandDispatch_Base( m_aMutex ), m_xContext( xContext ) { } @@ -44,17 +42,11 @@ void CommandDispatch::initialize() // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed -void SAL_CALL CommandDispatch::disposing() +void CommandDispatch::disposing(std::unique_lock<std::mutex>& rGuard) { Reference< uno::XInterface > xEventSource(static_cast< cppu::OWeakObject* >( this )); for( auto& rElement : m_aListeners ) - { - if( rElement.second ) - { - rElement.second->disposeAndClear( xEventSource ); - rElement.second.reset(); - } - } + rElement.second.disposeAndClear( rGuard, xEventSource ); m_aListeners.clear(); } @@ -64,24 +56,29 @@ void SAL_CALL CommandDispatch::dispatch( const util::URL& /* URL */, const Seque void SAL_CALL CommandDispatch::addStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) { - tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); - if( aIt == m_aListeners.end()) { - aIt = m_aListeners.insert( - m_aListeners.begin(), - tListenerMap::value_type( URL.Complete, new ::comphelper::OInterfaceContainerHelper2( m_aMutex ))); - } - OSL_ASSERT( aIt != m_aListeners.end()); + std::unique_lock g(m_aMutex); + tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); + if( aIt == m_aListeners.end()) + { + aIt = m_aListeners.emplace( + std::piecewise_construct, + std::forward_as_tuple(URL.Complete), + std::forward_as_tuple()).first; + } + assert( aIt != m_aListeners.end()); - aIt->second->addInterface( Control ); + aIt->second.addInterface( g, Control ); + } fireStatusEvent( URL.Complete, Control ); } void SAL_CALL CommandDispatch::removeStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) { + std::unique_lock g(m_aMutex); tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); if( aIt != m_aListeners.end()) - (*aIt).second->removeInterface( Control ); + (*aIt).second.removeInterface( g, Control ); } // ____ XModifyListener ____ @@ -132,24 +129,8 @@ void CommandDispatch::fireStatusEventForURL( tListenerMap::iterator aIt( m_aListeners.find( aURL.Complete )); if( aIt != m_aListeners.end()) { - if( aIt->second ) - { - ::comphelper::OInterfaceIteratorHelper2 aIntfIt( *((*aIt).second) ); - - while( aIntfIt.hasMoreElements()) - { - Reference< frame::XStatusListener > xListener( aIntfIt.next(), uno::UNO_QUERY ); - try - { - if( xListener.is()) - xListener->statusChanged( aEventToSend ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - } - } + std::unique_lock g(m_aMutex); + aIt->second.notifyEach(g, &css::frame::XStatusListener::statusChanged, aEventToSend); } } } |