diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-20 13:25:02 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-23 07:56:34 +0200 |
commit | db0f4ecd009f34e431b895c874c34d75186b3272 (patch) | |
tree | 25edbbf94183f16022bd4ef305fc698d9fef90b4 /dbaccess | |
parent | b395d9fd82cbc551d561c7a7ffe1751f5a35e339 (diff) |
use rtl::Reference in SbaXGridControl
instead of manual acquire/release
Change-Id: Ie103377d89419648d5f1d786933030b6f6166515
Diffstat (limited to 'dbaccess')
-rw-r--r-- | dbaccess/source/ui/browser/sbagrid.cxx | 37 | ||||
-rw-r--r-- | dbaccess/source/ui/inc/sbagrid.hxx | 3 |
2 files changed, 19 insertions, 21 deletions
diff --git a/dbaccess/source/ui/browser/sbagrid.cxx b/dbaccess/source/ui/browser/sbagrid.cxx index 606fc7dd937c..ed1603953805 100644 --- a/dbaccess/source/ui/browser/sbagrid.cxx +++ b/dbaccess/source/ui/browser/sbagrid.cxx @@ -207,8 +207,8 @@ void SAL_CALL SbaXGridControl::createPeer(const Reference< css::awt::XToolkit > aIter != m_aStatusMultiplexer.end(); ++aIter) { - if ((*aIter).second && (*aIter).second->getLength()) - xDisp->addStatusListener((*aIter).second, (*aIter).first); + if ((*aIter).second.is() && (*aIter).second->getLength()) + xDisp->addStatusListener((*aIter).second.get(), (*aIter).first); } } @@ -224,24 +224,23 @@ void SAL_CALL SbaXGridControl::addStatusListener( const Reference< XStatusListen ::osl::MutexGuard aGuard( GetMutex() ); if ( _rxListener.is() ) { - SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[ _rURL ]; - if ( !pMultiplexer ) + rtl::Reference<SbaXStatusMultiplexer>& xMultiplexer = m_aStatusMultiplexer[ _rURL ]; + if ( !xMultiplexer.is() ) { - pMultiplexer = new SbaXStatusMultiplexer( *this, GetMutex() ); - pMultiplexer->acquire(); + xMultiplexer = new SbaXStatusMultiplexer( *this, GetMutex() ); } - pMultiplexer->addInterface( _rxListener ); + xMultiplexer->addInterface( _rxListener ); if ( getPeer().is() ) { - if ( 1 == pMultiplexer->getLength() ) + if ( 1 == xMultiplexer->getLength() ) { // the first external listener for this URL Reference< XDispatch > xDisp( getPeer(), UNO_QUERY ); - xDisp->addStatusListener( pMultiplexer, _rURL ); + xDisp->addStatusListener( xMultiplexer.get(), _rURL ); } else { // already have other listeners for this URL - _rxListener->statusChanged( pMultiplexer->getLastEvent() ); + _rxListener->statusChanged( xMultiplexer->getLastEvent() ); } } } @@ -251,19 +250,18 @@ void SAL_CALL SbaXGridControl::removeStatusListener(const Reference< css::frame: { ::osl::MutexGuard aGuard( GetMutex() ); - SbaXStatusMultiplexer*& pMultiplexer = m_aStatusMultiplexer[_rURL]; - if (!pMultiplexer) + rtl::Reference<SbaXStatusMultiplexer>& xMultiplexer = m_aStatusMultiplexer[_rURL]; + if (!xMultiplexer.is()) { - pMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex()); - pMultiplexer->acquire(); + xMultiplexer = new SbaXStatusMultiplexer(*this,GetMutex()); } - if (getPeer().is() && pMultiplexer->getLength() == 1) + if (getPeer().is() && xMultiplexer->getLength() == 1) { Reference< css::frame::XDispatch > xDisp(getPeer(), UNO_QUERY); - xDisp->removeStatusListener(pMultiplexer, _rURL); + xDisp->removeStatusListener(xMultiplexer.get(), _rURL); } - pMultiplexer->removeInterface( _rxListener ); + xMultiplexer->removeInterface( _rxListener ); } void SAL_CALL SbaXGridControl::dispose() throw( RuntimeException, std::exception ) @@ -277,11 +275,10 @@ void SAL_CALL SbaXGridControl::dispose() throw( RuntimeException, std::exception aIter != m_aStatusMultiplexer.end(); ++aIter) { - if ((*aIter).second) + if ((*aIter).second.is()) { (*aIter).second->disposeAndClear(aEvt); - (*aIter).second->release(); - (*aIter).second = nullptr; + (*aIter).second.clear(); } } StatusMultiplexerArray().swap(m_aStatusMultiplexer); diff --git a/dbaccess/source/ui/inc/sbagrid.hxx b/dbaccess/source/ui/inc/sbagrid.hxx index 550c3f30dcd3..e9f5c2283d3f 100644 --- a/dbaccess/source/ui/inc/sbagrid.hxx +++ b/dbaccess/source/ui/inc/sbagrid.hxx @@ -30,6 +30,7 @@ #include <comphelper/uno3.hxx> #include "sbamultiplex.hxx" #include <svx/dataaccessdescriptor.hxx> +#include <rtl/ref.hxx> #include <map> #include <queue> @@ -53,7 +54,7 @@ namespace dbaui :public FmXGridControl ,public css::frame::XDispatch { - typedef std::map<css::util::URL, SbaXStatusMultiplexer*, SbaURLCompare> StatusMultiplexerArray; + typedef std::map<css::util::URL, rtl::Reference<SbaXStatusMultiplexer>, SbaURLCompare> StatusMultiplexerArray; StatusMultiplexerArray m_aStatusMultiplexer; public: |