[Libreoffice-commits] core.git: basic/source include/basic

Xisco Fauli anistenis at gmail.com
Fri Jun 3 10:26:13 UTC 2016


 basic/source/sbx/sbxvar.cxx |   32 ++++++++++++--------------------
 include/basic/sbxvar.hxx    |    3 ++-
 2 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit 0216b8dc6179fad02a9cbbc99898eef81f679f4f
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Wed Jun 1 00:55:54 2016 +0200

    tdf#89329: use unique_ptr for pImpl in sbxvar
    
    Change-Id: I74734c34e72ba5d508830dbcff88f0d3b93a0766
    Reviewed-on: https://gerrit.libreoffice.org/25742
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx
index 18d5054..1b52c46 100644
--- a/basic/source/sbx/sbxvar.cxx
+++ b/basic/source/sbx/sbxvar.cxx
@@ -62,7 +62,6 @@ class SbxVariableImpl
 
 SbxVariable::SbxVariable() : SbxValue()
 {
-    mpSbxVariableImpl = nullptr;
     pCst = nullptr;
     pParent = nullptr;
     nUserData = 0;
@@ -75,14 +74,13 @@ SbxVariable::SbxVariable( const SbxVariable& r )
       mpPar( r.mpPar ),
       pInfo( r.pInfo )
 {
-    mpSbxVariableImpl = nullptr;
-    if( r.mpSbxVariableImpl != nullptr )
+    if( r.mpImpl != nullptr )
     {
-        mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+        mpImpl.reset( new SbxVariableImpl( *r.mpImpl ) );
 #if HAVE_FEATURE_SCRIPTING
-        if( mpSbxVariableImpl->m_xComListener.is() )
+        if( mpImpl->m_xComListener.is() )
         {
-            registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+            registerComListenerVariableForBasic( this, mpImpl->m_pComListenerParentBasic );
         }
 #endif
     }
@@ -104,7 +102,6 @@ SbxVariable::SbxVariable( const SbxVariable& r )
 
 SbxVariable::SbxVariable( SbxDataType t, void* p ) : SbxValue( t, p )
 {
-    mpSbxVariableImpl = nullptr;
     pCst = nullptr;
     pParent = nullptr;
     nUserData = 0;
@@ -119,7 +116,6 @@ SbxVariable::~SbxVariable()
         removeDimAsNewRecoverItem( this );
     }
 #endif
-    delete mpSbxVariableImpl;
     delete pCst;
 }
 
@@ -349,21 +345,17 @@ sal_uInt16 SbxVariable::MakeHashCode( const OUString& rName )
 SbxVariable& SbxVariable::operator=( const SbxVariable& r )
 {
     SbxValue::operator=( r );
-    delete mpSbxVariableImpl;
-    if( r.mpSbxVariableImpl != nullptr )
+    mpImpl.reset();
+    if( r.mpImpl != nullptr )
     {
-        mpSbxVariableImpl = new SbxVariableImpl( *r.mpSbxVariableImpl );
+        mpImpl.reset( new SbxVariableImpl( *r.mpImpl ) );
 #if HAVE_FEATURE_SCRIPTING
-        if( mpSbxVariableImpl->m_xComListener.is() )
+        if( mpImpl->m_xComListener.is() )
         {
-            registerComListenerVariableForBasic( this, mpSbxVariableImpl->m_pComListenerParentBasic );
+            registerComListenerVariableForBasic( this, mpImpl->m_pComListenerParentBasic );
         }
 #endif
     }
-    else
-    {
-        mpSbxVariableImpl = nullptr;
-    }
     return *this;
 }
 
@@ -431,11 +423,11 @@ void SbxVariable::SetParent( SbxObject* p )
 
 SbxVariableImpl* SbxVariable::getImpl()
 {
-    if( mpSbxVariableImpl == nullptr )
+    if(!mpImpl)
     {
-        mpSbxVariableImpl = new SbxVariableImpl();
+        mpImpl.reset(new SbxVariableImpl);
     }
-    return mpSbxVariableImpl;
+    return mpImpl.get();
 }
 
 const OUString& SbxVariable::GetDeclareClassName()
diff --git a/include/basic/sbxvar.hxx b/include/basic/sbxvar.hxx
index a0800cf..0f66fcf 100644
--- a/include/basic/sbxvar.hxx
+++ b/include/basic/sbxvar.hxx
@@ -24,6 +24,7 @@
 #include <com/sun/star/bridge/oleautomation/Decimal.hpp>
 #include <basic/sbxcore.hxx>
 #include <basic/basicdllapi.h>
+#include <memory>
 
 
 class SbxDecimal;
@@ -227,7 +228,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue
 {
     friend class SbMethod;
 
-    SbxVariableImpl* mpSbxVariableImpl; // Impl data
+    std::unique_ptr<SbxVariableImpl> mpImpl; // Impl data
     SfxBroadcaster*  pCst;              // Broadcaster, if needed
     OUString         maName;            // Name, if available
     SbxArrayRef      mpPar;             // Parameter-Array, if set


More information about the Libreoffice-commits mailing list