Kaydet (Commit) 5f389168 authored tarafından Noel Grandin's avatar Noel Grandin

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/33163Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
Tested-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst b2a4c1e0
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment