summaryrefslogtreecommitdiff
path: root/chart2/source
diff options
context:
space:
mode:
Diffstat (limited to 'chart2/source')
-rw-r--r--chart2/source/controller/main/CommandDispatch.cxx29
-rw-r--r--chart2/source/controller/main/CommandDispatch.hxx3
2 files changed, 11 insertions, 21 deletions
diff --git a/chart2/source/controller/main/CommandDispatch.cxx b/chart2/source/controller/main/CommandDispatch.cxx
index 22e0a52c204f..ed6370a5228b 100644
--- a/chart2/source/controller/main/CommandDispatch.cxx
+++ b/chart2/source/controller/main/CommandDispatch.cxx
@@ -26,25 +26,6 @@ using namespace ::com::sun::star;
using ::com::sun::star::uno::Reference;
using ::com::sun::star::uno::Sequence;
-namespace
-{
-template< class Map >
- void lcl_DisposeAndClearAndDeleteAllMapElements(
- Map & rMap,
- const Reference< uno::XInterface > & xEventSource )
-{
- for( const auto& rElement : rMap )
- {
- if( rElement.second )
- {
- rElement.second->disposeAndClear( xEventSource );
- delete rElement.second;
- }
- }
-}
-
-} // anonymous namespace
-
namespace chart
{
@@ -65,7 +46,15 @@ void CommandDispatch::initialize()
/// is called when this is disposed
void SAL_CALL CommandDispatch::disposing()
{
- lcl_DisposeAndClearAndDeleteAllMapElements( m_aListeners, static_cast< cppu::OWeakObject* >( this ));
+ Reference< uno::XInterface > xEventSource(static_cast< cppu::OWeakObject* >( this ));
+ for( auto& rElement : m_aListeners )
+ {
+ if( rElement.second )
+ {
+ rElement.second->disposeAndClear( xEventSource );
+ rElement.second.reset();
+ }
+ }
m_aListeners.clear();
}
diff --git a/chart2/source/controller/main/CommandDispatch.hxx b/chart2/source/controller/main/CommandDispatch.hxx
index 1c7295186038..37de7c59c119 100644
--- a/chart2/source/controller/main/CommandDispatch.hxx
+++ b/chart2/source/controller/main/CommandDispatch.hxx
@@ -25,6 +25,7 @@
#include <com/sun/star/util/XModifyListener.hpp>
#include <map>
+#include <memory>
namespace com::sun::star::uno { class XComponentContext; }
namespace com::sun::star::util { class XURLTransformer; }
@@ -120,7 +121,7 @@ private:
css::uno::Reference< css::uno::XComponentContext > m_xContext;
css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
- typedef std::map< OUString, ::comphelper::OInterfaceContainerHelper2* >
+ typedef std::map< OUString, std::unique_ptr<::comphelper::OInterfaceContainerHelper2> >
tListenerMap;
tListenerMap m_aListeners;