diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-16 13:56:51 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-01-17 06:37:47 +0000 |
commit | 5f38916888f980898707553e58a3e0d836c5198c (patch) | |
tree | 8c0116098edfa3b0f195e043ef729dc2826ec505 /UnoControls | |
parent | b2a4c1e085a14f79cb1765fe2ade443afc273b9a (diff) |
use rtl::Reference in BaseControl
no need to hold both raw pointer and a uno::Reference to the same object
Change-Id: I6aa2b2e259aed77ab038fc72a3ece7165e477f50
Reviewed-on: https://gerrit.libreoffice.org/33163
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls')
-rw-r--r-- | UnoControls/inc/basecontrol.hxx | 4 | ||||
-rw-r--r-- | UnoControls/source/base/basecontrol.cxx | 21 |
2 files changed, 11 insertions, 14 deletions
diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx index fbf1686d2a51..8e8b93784b7f 100644 --- a/UnoControls/inc/basecontrol.hxx +++ b/UnoControls/inc/basecontrol.hxx @@ -86,6 +86,7 @@ #include <tools/colordata.hxx> #include <cppuhelper/weak.hxx> #include <cppuhelper/component.hxx> +#include <rtl/ref.hxx> #include "multiplexer.hxx" @@ -383,8 +384,7 @@ private: css::uno::Reference< css::uno::XComponentContext > m_xComponentContext; css::uno::Reference< css::uno::XInterface > m_xDelegator; - OMRCListenerMultiplexerHelper* m_pMultiplexer; // multiplex events - css::uno::Reference< css::uno::XInterface > m_xMultiplexer; + rtl::Reference<OMRCListenerMultiplexerHelper> m_xMultiplexer; // multiplex events css::uno::Reference< css::uno::XInterface > m_xContext; css::uno::Reference< css::awt::XWindowPeer > m_xPeer; css::uno::Reference< css::awt::XWindow > m_xPeerWindow; diff --git a/UnoControls/source/base/basecontrol.cxx b/UnoControls/source/base/basecontrol.cxx index 457dd5cb7821..98d927aa2b1f 100644 --- a/UnoControls/source/base/basecontrol.cxx +++ b/UnoControls/source/base/basecontrol.cxx @@ -40,7 +40,6 @@ using namespace ::com::sun::star::awt; namespace unocontrols{ -#define DEFAULT_PMULTIPLEXER nullptr #define DEFAULT_X 0 #define DEFAULT_Y 0 #define DEFAULT_WIDTH 100 @@ -55,7 +54,6 @@ BaseControl::BaseControl( const Reference< XComponentContext >& rxContext ) : IMPL_MutexContainer ( ) , OComponentHelper ( m_aMutex ) , m_xComponentContext ( rxContext ) - , m_pMultiplexer ( DEFAULT_PMULTIPLEXER ) , m_nX ( DEFAULT_X ) , m_nY ( DEFAULT_Y ) , m_nWidth ( DEFAULT_WIDTH ) @@ -220,10 +218,10 @@ void SAL_CALL BaseControl::dispose() throw( RuntimeException, std::exception ) // Ready for multithreading MutexGuard aGuard( m_aMutex ); - if ( m_pMultiplexer != nullptr ) + if ( m_xMultiplexer.is() ) { // to all other paint, focus, etc. - m_pMultiplexer->disposeAndClear(); + m_xMultiplexer->disposeAndClear(); } // set the service manager to disposed @@ -244,10 +242,10 @@ void SAL_CALL BaseControl::dispose() throw( RuntimeException, std::exception ) m_xPeerWindow.clear(); m_xPeer.clear(); - if ( m_pMultiplexer != nullptr ) + if ( m_xMultiplexer.is() ) { // take changes on multiplexer - m_pMultiplexer->setPeer( Reference< XWindow >() ); + m_xMultiplexer->setPeer( Reference< XWindow >() ); } } @@ -310,9 +308,9 @@ void SAL_CALL BaseControl::createPeer( const Reference< XToolkit >& xToo if ( m_xPeerWindow.is() ) { - if ( m_pMultiplexer != nullptr ) + if ( m_xMultiplexer.is() ) { - m_pMultiplexer->setPeer( m_xPeerWindow ); + m_xMultiplexer->setPeer( m_xPeerWindow ); } // create new referenz to xgraphics for painting on a peer @@ -763,13 +761,12 @@ void BaseControl::impl_recalcLayout( const WindowEvent& /*aEvent*/ ) OMRCListenerMultiplexerHelper* BaseControl::impl_getMultiplexer() { - if ( m_pMultiplexer == nullptr ) + if ( !m_xMultiplexer.is() ) { - m_pMultiplexer = new OMRCListenerMultiplexerHelper( static_cast<XWindow*>(this), m_xPeerWindow ); - m_xMultiplexer.set( static_cast<OWeakObject*>(m_pMultiplexer), UNO_QUERY ); + m_xMultiplexer = new OMRCListenerMultiplexerHelper( static_cast<XWindow*>(this), m_xPeerWindow ); } - return m_pMultiplexer; + return m_xMultiplexer.get(); } } // namespace unocontrols |