diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2022-09-01 19:08:37 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-09-02 09:01:50 +0200 |
commit | 91c5e7a924830dbefeaedd4e342f6f2d69e1b1ea (patch) | |
tree | 772cb564405f6998c8358720746b5c97a6d12f1f /chart2 | |
parent | ae3965f6cc87a7d57da319370ef1d783682100a8 (diff) |
no need to use unique_ptr for this map in chart::CommandDispatch
map is already a node based data structure, so the values will stay
in the same place in memory
Change-Id: I255d99cd2014f33524480e218d2d9cd5ca812375
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139235
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/controller/main/CommandDispatch.cxx | 42 | ||||
-rw-r--r-- | chart2/source/controller/main/CommandDispatch.hxx | 2 |
2 files changed, 18 insertions, 26 deletions
diff --git a/chart2/source/controller/main/CommandDispatch.cxx b/chart2/source/controller/main/CommandDispatch.cxx index f06c877ee525..c7e4f622c522 100644 --- a/chart2/source/controller/main/CommandDispatch.cxx +++ b/chart2/source/controller/main/CommandDispatch.cxx @@ -48,13 +48,7 @@ void SAL_CALL CommandDispatch::disposing() { 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( xEventSource ); m_aListeners.clear(); } @@ -67,13 +61,14 @@ void SAL_CALL CommandDispatch::addStatusListener( const Reference< frame::XStatu 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::OInterfaceContainerHelper3<css::frame::XStatusListener>( m_aMutex ))); + aIt = m_aListeners.emplace( + std::piecewise_construct, + std::forward_as_tuple(URL.Complete), + std::forward_as_tuple( m_aMutex )).first; } - OSL_ASSERT( aIt != m_aListeners.end()); + assert( aIt != m_aListeners.end()); - aIt->second->addInterface( Control ); + aIt->second.addInterface( Control ); fireStatusEvent( URL.Complete, Control ); } @@ -81,7 +76,7 @@ void SAL_CALL CommandDispatch::removeStatusListener( const Reference< frame::XSt { tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); if( aIt != m_aListeners.end()) - (*aIt).second->removeInterface( Control ); + (*aIt).second.removeInterface( Control ); } // ____ XModifyListener ____ @@ -132,20 +127,17 @@ void CommandDispatch::fireStatusEventForURL( tListenerMap::iterator aIt( m_aListeners.find( aURL.Complete )); if( aIt != m_aListeners.end()) { - if( aIt->second ) - { - ::comphelper::OInterfaceIteratorHelper3 aIntfIt( *((*aIt).second) ); + ::comphelper::OInterfaceIteratorHelper3 aIntfIt( aIt->second ); - while( aIntfIt.hasMoreElements()) + while( aIntfIt.hasMoreElements()) + { + try + { + aIntfIt.next()->statusChanged( aEventToSend ); + } + catch( const uno::Exception & ) { - try - { - aIntfIt.next()->statusChanged( aEventToSend ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + DBG_UNHANDLED_EXCEPTION("chart2"); } } } diff --git a/chart2/source/controller/main/CommandDispatch.hxx b/chart2/source/controller/main/CommandDispatch.hxx index 16e0b5ab72bc..d156b8d8cf8d 100644 --- a/chart2/source/controller/main/CommandDispatch.hxx +++ b/chart2/source/controller/main/CommandDispatch.hxx @@ -121,7 +121,7 @@ private: css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - typedef std::map< OUString, std::unique_ptr<::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener>> > + typedef std::map< OUString, ::comphelper::OInterfaceContainerHelper3<css::frame::XStatusListener> > tListenerMap; tListenerMap m_aListeners; |