diff options
author | Noel Grandin <noel@peralex.com> | 2016-06-02 14:53:50 +0200 |
---|---|---|
committer | Noel Grandin <noelgrandin@gmail.com> | 2016-06-06 07:01:51 +0000 |
commit | 7d1b01070c330d45212cd69ea692b2263c23c2a6 (patch) | |
tree | 7ae6ecdd69cd3d8b6ce4431a39034186695497c0 /unotools | |
parent | 9f138ffe9da2f448a455f4b51facab82e5e243d7 (diff) |
remove some manual ref counting in svx and xmloff
Change-Id: Ica0b6ff8ff7fa9e65cd758160d6e3ea7110ebb46
Reviewed-on: https://gerrit.libreoffice.org/25824
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/misc/eventlisteneradapter.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/unotools/source/misc/eventlisteneradapter.cxx b/unotools/source/misc/eventlisteneradapter.cxx index 9eaa1bdf3e45..f33811a463a6 100644 --- a/unotools/source/misc/eventlisteneradapter.cxx +++ b/unotools/source/misc/eventlisteneradapter.cxx @@ -24,6 +24,7 @@ #include <unotools/eventlisteneradapter.hxx> #include <osl/diagnose.h> #include <cppuhelper/implbase.hxx> +#include <rtl/ref.hxx> namespace utl { @@ -92,7 +93,7 @@ namespace utl struct OEventListenerAdapterImpl { public: - ::std::vector< void* > aListeners; + std::vector< rtl::Reference<OEventListenerImpl> > aListeners; }; //= OEventListenerAdapter @@ -112,32 +113,26 @@ namespace utl if ( m_pImpl->aListeners.empty() ) return; - ::std::vector< void* >::iterator dispose = m_pImpl->aListeners.begin(); + auto it = m_pImpl->aListeners.begin(); do { - OEventListenerImpl* pListenerImpl = static_cast< OEventListenerImpl* >( *dispose ); + rtl::Reference<OEventListenerImpl>& pListenerImpl = *it; if ( pListenerImpl->getComponent().get() == _rxComp.get() ) { pListenerImpl->dispose(); - pListenerImpl->release(); - dispose = m_pImpl->aListeners.erase( dispose ); + it = m_pImpl->aListeners.erase( it ); } else - ++dispose; + ++it; } - while ( dispose != m_pImpl->aListeners.end() ); + while ( it != m_pImpl->aListeners.end() ); } void OEventListenerAdapter::stopAllComponentListening( ) { - for ( ::std::vector< void* >::const_iterator aDisposeLoop = m_pImpl->aListeners.begin(); - aDisposeLoop != m_pImpl->aListeners.end(); - ++aDisposeLoop - ) + for ( const auto & i : m_pImpl->aListeners ) { - OEventListenerImpl* pListenerImpl = static_cast< OEventListenerImpl* >(*aDisposeLoop); - pListenerImpl->dispose(); - pListenerImpl->release(); + i->dispose(); } m_pImpl->aListeners.clear(); } @@ -151,7 +146,6 @@ namespace utl } OEventListenerImpl* pListenerImpl = new OEventListenerImpl(this, _rxComp); - pListenerImpl->acquire(); m_pImpl->aListeners.push_back(pListenerImpl); } |