[Libreoffice-commits] core.git: UnoControls/inc UnoControls/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jan 17 06:38:13 UTC 2017


 UnoControls/inc/basecontrol.hxx         |    4 ++--
 UnoControls/source/base/basecontrol.cxx |   21 +++++++++------------
 2 files changed, 11 insertions(+), 14 deletions(-)

New commits:
commit 5f38916888f980898707553e58a3e0d836c5198c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 16 13:56:51 2017 +0200

    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 at collabora.co.uk>
    Tested-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/UnoControls/inc/basecontrol.hxx b/UnoControls/inc/basecontrol.hxx
index fbf1686..8e8b937 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 457dd5c..98d927a 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


More information about the Libreoffice-commits mailing list