diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-16 15:05:33 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-19 08:58:46 +0200 |
commit | 44853cc8be2c7c6174b353e849a757aefa49f604 (patch) | |
tree | dc0f46398ef724b50031810616243ccdda768df2 /basic | |
parent | 000fa4c4952cdc3d63f91a63eb4b3da83e5990ca (diff) |
loplugin:useuniqeptr in SbxVariable
Change-Id: I788ec594589d9708e12db83a7371b5a8d9fed38c
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 13 | ||||
-rw-r--r-- | basic/source/sbx/sbxvar.cxx | 19 |
2 files changed, 13 insertions, 19 deletions
diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index de486209750a..f0ee0f7f7f56 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -2080,7 +2080,7 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller ) // #100883 Own Broadcast for SbMethod void SbMethod::Broadcast( SfxHintId nHintId ) { - if( pCst && !IsSet( SbxFlagBits::NoBroadcast ) ) + if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) ) { // Because the method could be called from outside, test here once again // the authorisation @@ -2095,8 +2095,7 @@ void SbMethod::Broadcast( SfxHintId nHintId ) pMod->Compile(); // Block broadcasts while creating new method - SfxBroadcaster* pSave = pCst; - pCst = nullptr; + std::unique_ptr<SfxBroadcaster> pSaveBroadcaster = std::move(mpBroadcaster); SbMethod* pThisCopy = new SbMethod( *this ); SbMethodRef xHolder = pThisCopy; if( mpPar.is() ) @@ -2108,14 +2107,14 @@ void SbMethod::Broadcast( SfxHintId nHintId ) SetParameters( nullptr ); } - pCst = pSave; - pSave->Broadcast( SbxHint( nHintId, pThisCopy ) ); + mpBroadcaster = std::move(pSaveBroadcaster); + mpBroadcaster->Broadcast( SbxHint( nHintId, pThisCopy ) ); SbxFlagBits nSaveFlags = GetFlags(); SetFlag( SbxFlagBits::ReadWrite ); - pCst = nullptr; + pSaveBroadcaster = std::move(mpBroadcaster); Put( pThisCopy->GetValues_Impl() ); - pCst = pSave; + mpBroadcaster = std::move(pSaveBroadcaster); SetFlags( nSaveFlags ); } } diff --git a/basic/source/sbx/sbxvar.cxx b/basic/source/sbx/sbxvar.cxx index 17db37db5c37..30088e0746f9 100644 --- a/basic/source/sbx/sbxvar.cxx +++ b/basic/source/sbx/sbxvar.cxx @@ -56,7 +56,6 @@ class SbxVariableImpl SbxVariable::SbxVariable() : SbxValue() { - pCst = nullptr; pParent = nullptr; nUserData = 0; nHash = 0; @@ -78,7 +77,6 @@ SbxVariable::SbxVariable( const SbxVariable& r ) } #endif } - pCst = nullptr; if( r.CanRead() ) { pParent = r.pParent; @@ -111,7 +109,6 @@ void SbxEnsureParentVariable::SetParent(SbxObject* p) SbxVariable::SbxVariable( SbxDataType t ) : SbxValue( t ) { - pCst = nullptr; pParent = nullptr; nUserData = 0; nHash = 0; @@ -125,18 +122,18 @@ SbxVariable::~SbxVariable() removeDimAsNewRecoverItem( this ); } #endif - delete pCst; + mpBroadcaster.reset(); } // Broadcasting SfxBroadcaster& SbxVariable::GetBroadcaster() { - if( !pCst ) + if( !mpBroadcaster ) { - pCst = new SfxBroadcaster; + mpBroadcaster.reset( new SfxBroadcaster ); } - return *pCst; + return *mpBroadcaster; } SbxArray* SbxVariable::GetParameters() const @@ -150,7 +147,7 @@ SbxArray* SbxVariable::GetParameters() const void SbxVariable::Broadcast( SfxHintId nHintId ) { - if( pCst && !IsSet( SbxFlagBits::NoBroadcast ) ) + if( mpBroadcaster && !IsSet( SbxFlagBits::NoBroadcast ) ) { // Because the method could be called from outside, check the // rights here again @@ -174,8 +171,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) SbxVariableRef aBroadcastGuard(this); // Avoid further broadcasting - SfxBroadcaster* pSave = pCst; - pCst = nullptr; + std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster); SbxFlagBits nSaveFlags = GetFlags(); SetFlag( SbxFlagBits::ReadWrite ); if( mpPar.is() ) @@ -184,8 +180,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) mpPar->GetRef( 0 ) = this; } pSave->Broadcast( SbxHint( nHintId, this ) ); - delete pCst; // who knows already, onto which thoughts someone comes? - pCst = pSave; + mpBroadcaster = std::move(pSave); SetFlags( nSaveFlags ); } } |