diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 18d50540478a..1b52c46386d0 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 a0800cf40e04..0f66fcf75799 100644 --- a/include/basic/sbxvar.hxx +++ b/include/basic/sbxvar.hxx @@ -24,6 +24,7 @@ #include #include #include +#include class SbxDecimal; @@ -227,7 +228,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue { friend class SbMethod; - SbxVariableImpl* mpSbxVariableImpl; // Impl data + std::unique_ptr mpImpl; // Impl data SfxBroadcaster* pCst; // Broadcaster, if needed OUString maName; // Name, if available SbxArrayRef mpPar; // Parameter-Array, if set