[Libreoffice-commits] core.git: forms/source

Noel Grandin noel at peralex.com
Wed Jun 8 10:33:19 UTC 2016


 forms/source/component/DatabaseForm.cxx       |   21 ++++-----------------
 forms/source/component/DatabaseForm.hxx       |    4 ++--
 forms/source/component/clickableimage.cxx     |   12 +++---------
 forms/source/component/clickableimage.hxx     |    4 ++--
 forms/source/richtext/clipboarddispatcher.cxx |    7 ++-----
 forms/source/richtext/clipboarddispatcher.hxx |    3 ++-
 6 files changed, 15 insertions(+), 36 deletions(-)

New commits:
commit 6cd3882bec5aa63b61d7cc9db66ff3bae5d43f1c
Author: Noel Grandin <noel at peralex.com>
Date:   Wed Jun 8 10:31:32 2016 +0200

    remove some manual ref-counting in forms
    
    Change-Id: I6334dca6e98bfd4531033bec203518ca27f64bc0
    Reviewed-on: https://gerrit.libreoffice.org/26049
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/forms/source/component/DatabaseForm.cxx b/forms/source/component/DatabaseForm.cxx
index 8d9dcf0..c43fd3a 100644
--- a/forms/source/component/DatabaseForm.cxx
+++ b/forms/source/component/DatabaseForm.cxx
@@ -261,11 +261,9 @@ ODatabaseForm::ODatabaseForm(const Reference<XComponentContext>& _rxContext)
     ,m_aResetListeners( *this, m_aMutex )
     ,m_aPropertyBagHelper( *this )
     ,m_pAggregatePropertyMultiplexer(nullptr)
-    ,m_pGroupManager( nullptr )
     ,m_aParameterManager( m_aMutex, _rxContext )
     ,m_aFilterManager()
     ,m_pLoadTimer(nullptr)
-    ,m_pThread(nullptr)
     ,m_nResetsPending(0)
     ,m_nPrivileges(0)
     ,m_bInsertOnly( false )
@@ -299,11 +297,9 @@ ODatabaseForm::ODatabaseForm( const ODatabaseForm& _cloneSource )
     ,m_aResetListeners( *this, m_aMutex )
     ,m_aPropertyBagHelper( *this )
     ,m_pAggregatePropertyMultiplexer( nullptr )
-    ,m_pGroupManager( nullptr )
     ,m_aParameterManager( m_aMutex, _cloneSource.m_xContext )
     ,m_aFilterManager()
     ,m_pLoadTimer( nullptr )
-    ,m_pThread( nullptr )
     ,m_nResetsPending( 0 )
     ,m_nPrivileges( 0 )
     ,m_bInsertOnly( _cloneSource.m_bInsertOnly )
@@ -423,15 +419,12 @@ void ODatabaseForm::impl_construct()
     osl_atomic_decrement( &m_refCount );
 
     m_pGroupManager = new OGroupManager( this );
-    m_pGroupManager->acquire();
 }
 
 
 ODatabaseForm::~ODatabaseForm()
 {
-
-    m_pGroupManager->release();
-    m_pGroupManager = nullptr;
+    m_pGroupManager.clear();
 
     if (m_xAggregate.is())
         m_xAggregate->setDelegator( nullptr );
@@ -1281,11 +1274,7 @@ void ODatabaseForm::disposing()
     // cancel the submit/reset-thread
     {
         ::osl::MutexGuard aGuard( m_aMutex );
-        if (m_pThread)
-        {
-            m_pThread->release();
-            m_pThread = nullptr;
-        }
+        m_pThread.clear();
     }
 
     EventObject aEvt(static_cast<XWeak*>(this));
@@ -1937,10 +1926,9 @@ void SAL_CALL ODatabaseForm::reset() throw( RuntimeException, std::exception )
         ++m_nResetsPending;
         // create an own thread if we have (approve-)reset-listeners (so the listeners can't do that much damage
         // to this thread which is probably the main one)
-        if (!m_pThread)
+        if (!m_pThread.is())
         {
             m_pThread = new OFormSubmitResetThread(this);
-            m_pThread->acquire();
             m_pThread->create();
         }
         EventObject aEvt;
@@ -2108,10 +2096,9 @@ void SAL_CALL ODatabaseForm::submit( const Reference<XControl>& Control,
     {
         // create an own thread if we have (approve-)submit-listeners (so the listeners can't do that much damage
         // to this thread which is probably the main one)
-        if (!m_pThread)
+        if (!m_pThread.is())
         {
             m_pThread = new OFormSubmitResetThread(this);
-            m_pThread->acquire();
             m_pThread->create();
         }
         m_pThread->addEvent(&MouseEvt, Control, true);
diff --git a/forms/source/component/DatabaseForm.hxx b/forms/source/component/DatabaseForm.hxx
index 1138c2a..48ae9b6 100644
--- a/forms/source/component/DatabaseForm.hxx
+++ b/forms/source/component/DatabaseForm.hxx
@@ -175,12 +175,12 @@ class ODatabaseForm :public OFormComponents
     ::dbtools::WarningsContainer    m_aWarnings;
     OPropertyChangeMultiplexer* m_pAggregatePropertyMultiplexer;
     // Management of the Control Groups
-    OGroupManager*              m_pGroupManager;
+    rtl::Reference<OGroupManager>   m_pGroupManager;
     ::dbtools::ParameterManager m_aParameterManager;
     ::dbtools::FilterManager    m_aFilterManager;
     Timer*                      m_pLoadTimer;
 
-    OFormSubmitResetThread*     m_pThread;
+    rtl::Reference<OFormSubmitResetThread>  m_pThread;
     OUString                    m_sCurrentErrorContext;
     // will be used as additional context information
     // when an exception is catched and forwarded to the listeners
diff --git a/forms/source/component/clickableimage.cxx b/forms/source/component/clickableimage.cxx
index 82aafb5..3de2652 100644
--- a/forms/source/component/clickableimage.cxx
+++ b/forms/source/component/clickableimage.cxx
@@ -83,7 +83,6 @@ namespace frm
 
     OClickableImageBaseControl::OClickableImageBaseControl(const Reference<XComponentContext>& _rxFactory, const OUString& _aService)
         :OControl(_rxFactory, _aService)
-        ,m_pThread(nullptr)
         ,m_aSubmissionVetoListeners( m_aMutex )
         ,m_aApproveActionListeners( m_aMutex )
         ,m_aActionListeners( m_aMutex )
@@ -150,11 +149,7 @@ namespace frm
 
         {
             ::osl::MutexGuard aGuard( m_aMutex );
-            if( m_pThread )
-            {
-                m_pThread->release();
-                m_pThread = nullptr;
-            }
+            m_pThread.clear();
         }
 
         OControl::disposing();
@@ -163,13 +158,12 @@ namespace frm
 
     OImageProducerThread_Impl* OClickableImageBaseControl::getImageProducerThread()
     {
-        if ( !m_pThread )
+        if ( !m_pThread.is() )
         {
             m_pThread = new OImageProducerThread_Impl( this );
-            m_pThread->acquire();
             m_pThread->create();
         }
-        return m_pThread;
+        return m_pThread.get();
     }
 
 
diff --git a/forms/source/component/clickableimage.hxx b/forms/source/component/clickableimage.hxx
index ccb6b83..b1ea4dc 100644
--- a/forms/source/component/clickableimage.hxx
+++ b/forms/source/component/clickableimage.hxx
@@ -187,10 +187,10 @@ namespace frm
         friend class OImageProducerThread_Impl;
 
     private:
-        OImageProducerThread_Impl*          m_pThread;
+        rtl::Reference<OImageProducerThread_Impl>  m_pThread;
         ::comphelper::OInterfaceContainerHelper2   m_aSubmissionVetoListeners;
         ::std::unique_ptr< ControlFeatureInterception >
-                                            m_pFeatureInterception;
+                                                   m_pFeatureInterception;
 
     protected:
         ::comphelper::OInterfaceContainerHelper2 m_aApproveActionListeners;
diff --git a/forms/source/richtext/clipboarddispatcher.cxx b/forms/source/richtext/clipboarddispatcher.cxx
index cb920ff..53f58dc 100644
--- a/forms/source/richtext/clipboarddispatcher.cxx
+++ b/forms/source/richtext/clipboarddispatcher.cxx
@@ -130,11 +130,9 @@ namespace frm
 
     OPasteClipboardDispatcher::OPasteClipboardDispatcher( EditView& _rView )
         :OClipboardDispatcher( _rView, ePaste )
-        ,m_pClipListener( nullptr )
         ,m_bPastePossible( false )
     {
         m_pClipListener = new TransferableClipboardListener( LINK( this, OPasteClipboardDispatcher, OnClipboardChanged ) );
-        m_pClipListener->acquire();
         m_pClipListener->AddListener( _rView.GetWindow() );
 
         // initial state
@@ -166,13 +164,12 @@ namespace frm
     void OPasteClipboardDispatcher::disposing( ::osl::ClearableMutexGuard& _rClearBeforeNotify )
     {
         OSL_ENSURE( getEditView() && getEditView()->GetWindow(), "OPasteClipboardDispatcher::disposing: EditView should not (yet) be disfunctional here!" );
-        if (m_pClipListener)
+        if (m_pClipListener.is())
         {
             if (getEditView() && getEditView()->GetWindow())
                 m_pClipListener->RemoveListener( getEditView()->GetWindow() );
 
-            m_pClipListener->release();
-            m_pClipListener = nullptr;
+            m_pClipListener.clear();
         }
 
         OClipboardDispatcher::disposing( _rClearBeforeNotify );
diff --git a/forms/source/richtext/clipboarddispatcher.hxx b/forms/source/richtext/clipboarddispatcher.hxx
index 2384cc0..d0041b3 100644
--- a/forms/source/richtext/clipboarddispatcher.hxx
+++ b/forms/source/richtext/clipboarddispatcher.hxx
@@ -22,6 +22,7 @@
 
 #include "featuredispatcher.hxx"
 #include <tools/link.hxx>
+#include <rtl/ref.hxx>
 
 class TransferableClipboardListener;
 class TransferableDataHelper;
@@ -65,7 +66,7 @@ namespace frm
     class OPasteClipboardDispatcher : public OClipboardDispatcher
     {
     private:
-        TransferableClipboardListener*  m_pClipListener;
+        rtl::Reference<TransferableClipboardListener>  m_pClipListener;
         bool                        m_bPastePossible;
 
     public:


More information about the Libreoffice-commits mailing list