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

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


 ucb/source/sorter/sortdynres.cxx |   45 +++++++++++++--------------------------
 ucb/source/sorter/sortdynres.hxx |   15 +++++--------
 2 files changed, 22 insertions(+), 38 deletions(-)

New commits:
commit 4b668a5071b2f0bc74f62873679fba5c6c2d04ce
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Mon Jan 16 14:07:28 2017 +0200

    use rtl::Reference in SortedDynamicResultSet
    
    instead of storing both raw pointers and uno::Reference
    
    Change-Id: Ifcc9daf95d4b2583c9bc4b06deb65a2e618ac1e0
    Reviewed-on: https://gerrit.libreoffice.org/33168
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/ucb/source/sorter/sortdynres.cxx b/ucb/source/sorter/sortdynres.cxx
index ead0def..e3dcfcc 100644
--- a/ucb/source/sorter/sortdynres.cxx
+++ b/ucb/source/sorter/sortdynres.cxx
@@ -63,18 +63,13 @@ SortedDynamicResultSet::SortedDynamicResultSet(
                         const Reference < XComponentContext > &rxContext )
 {
     mpDisposeEventListeners = nullptr;
-    mpOwnListener           = new SortedDynamicResultSetListener( this );
-
-    mxOwnListener.set( mpOwnListener );
+    mxOwnListener           = new SortedDynamicResultSetListener( this );
 
     mxOriginal  = xOriginal;
     maOptions   = aOptions;
     mxCompFac   = xCompFac;
     m_xContext  = rxContext;
 
-    mpOne = nullptr;
-    mpTwo = nullptr;
-
     mbGotWelcome    = false;
     mbUseOne        = true;
     mbStatic        = false;
@@ -83,7 +78,7 @@ SortedDynamicResultSet::SortedDynamicResultSet(
 
 SortedDynamicResultSet::~SortedDynamicResultSet()
 {
-    mpOwnListener->impl_OwnerDies();
+    mxOwnListener->impl_OwnerDies();
     mxOwnListener.clear();
 
     delete mpDisposeEventListeners;
@@ -91,9 +86,6 @@ SortedDynamicResultSet::~SortedDynamicResultSet()
     mxOne.clear();
     mxTwo.clear();
     mxOriginal.clear();
-
-    mpOne = nullptr;
-    mpTwo = nullptr;
 }
 
 // XServiceInfo methods.
@@ -134,8 +126,6 @@ void SAL_CALL SortedDynamicResultSet::dispose()
     mxTwo.clear();
     mxOriginal.clear();
 
-    mpOne = nullptr;
-    mpTwo = nullptr;
     mbUseOne = true;
 }
 
@@ -178,12 +168,11 @@ SortedDynamicResultSet::getStaticResultSet()
 
     if ( mxOriginal.is() )
     {
-        mpOne = new SortedResultSet( mxOriginal->getStaticResultSet() );
-        mxOne = mpOne;
-        mpOne->Initialize( maOptions, mxCompFac );
+        mxOne = new SortedResultSet( mxOriginal->getStaticResultSet() );
+        mxOne->Initialize( maOptions, mxCompFac );
     }
 
-    return mxOne;
+    return mxOne.get();
 }
 
 
@@ -201,7 +190,7 @@ SortedDynamicResultSet::setListener( const Reference< XDynamicResultSetListener
     mxListener = Listener;
 
     if ( mxOriginal.is() )
-        mxOriginal->setListener( mxOwnListener );
+        mxOriginal->setListener( mxOwnListener.get() );
 }
 
 
@@ -292,14 +281,14 @@ void SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
         if ( mbUseOne )
         {
             mbUseOne = false;
-            mpTwo->CopyData( mpOne );
-            pCurSet = mpTwo;
+            mxTwo->CopyData( mxOne.get() );
+            pCurSet = mxTwo.get();
         }
         else
         {
             mbUseOne = true;
-            mpOne->CopyData( mpTwo );
-            pCurSet = mpOne;
+            mxOne->CopyData( mxTwo.get() );
+            pCurSet = mxOne.get();
         }
     }
 
@@ -330,17 +319,15 @@ void SortedDynamicResultSet::impl_notify( const ListEvent& Changes )
                     WelcomeDynamicResultSetStruct aWelcome;
                     if ( aAction.ActionInfo >>= aWelcome )
                     {
-                        mpTwo = new SortedResultSet( aWelcome.Old );
-                        mxTwo = mpTwo;
-                        mpOne = new SortedResultSet( aWelcome.New );
-                        mxOne = mpOne;
-                        mpOne->Initialize( maOptions, mxCompFac );
+                        mxTwo = new SortedResultSet( aWelcome.Old );
+                        mxOne = new SortedResultSet( aWelcome.New );
+                        mxOne->Initialize( maOptions, mxCompFac );
                         mbGotWelcome = true;
                         mbUseOne = true;
-                        pCurSet = mpOne;
+                        pCurSet = mxOne.get();
 
-                        aWelcome.Old = mxTwo;
-                        aWelcome.New = mxOne;
+                        aWelcome.Old = mxTwo.get();
+                        aWelcome.New = mxOne.get();
 
                         ListAction *pWelcomeAction = new ListAction;
                         pWelcomeAction->ActionInfo <<= aWelcome;
diff --git a/ucb/source/sorter/sortdynres.hxx b/ucb/source/sorter/sortdynres.hxx
index a766f5f..85a2ec2 100644
--- a/ucb/source/sorter/sortdynres.hxx
+++ b/ucb/source/sorter/sortdynres.hxx
@@ -47,24 +47,21 @@ class SortedDynamicResultSet: public cppu::WeakImplHelper <
     comphelper::OInterfaceContainerHelper2 *mpDisposeEventListeners;
 
     css::uno::Reference < css::ucb::XDynamicResultSetListener > mxListener;
-    css::uno::Reference < css::ucb::XDynamicResultSetListener > mxOwnListener;
 
-    css::uno::Reference < css::sdbc::XResultSet >            mxOne;
-    css::uno::Reference < css::sdbc::XResultSet >            mxTwo;
     css::uno::Reference < css::ucb::XDynamicResultSet >      mxOriginal;
     css::uno::Sequence  < css::ucb::NumberedSortingInfo >    maOptions;
     css::uno::Reference < css::ucb::XAnyCompareFactory >     mxCompFac;
     css::uno::Reference < css::uno::XComponentContext >      m_xContext;
 
-    SortedResultSet*                    mpOne;
-    SortedResultSet*                    mpTwo;
-    SortedDynamicResultSetListener*     mpOwnListener;
+    rtl::Reference<SortedResultSet>                          mxOne;
+    rtl::Reference<SortedResultSet>                          mxTwo;
+    rtl::Reference<SortedDynamicResultSetListener>           mxOwnListener;
 
     EventList                           maActions;
     osl::Mutex                          maMutex;
-    bool                            mbGotWelcome:1;
-    bool                            mbUseOne:1;
-    bool                            mbStatic:1;
+    bool                                mbGotWelcome:1;
+    bool                                mbUseOne:1;
+    bool                                mbStatic:1;
 
 private:
     void                SendNotify();


More information about the Libreoffice-commits mailing list