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>
This commit is contained in:
Noel Grandin
2022-09-02 09:01:50 +02:00
committed by Noel Grandin
parent ae3965f6cc
commit 91c5e7a924
2 changed files with 18 additions and 26 deletions
@@ -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
{
try
{
aIntfIt.next()->statusChanged( aEventToSend );
}
catch( const uno::Exception & )
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
aIntfIt.next()->statusChanged( aEventToSend );
}
catch( const uno::Exception & )
{
DBG_UNHANDLED_EXCEPTION("chart2");
}
}
}
@@ -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;