Kaydet (Commit) 44853cc8 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqeptr in SbxVariable

Change-Id: I788ec594589d9708e12db83a7371b5a8d9fed38c
üst 000fa4c4
...@@ -2080,7 +2080,7 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller ) ...@@ -2080,7 +2080,7 @@ ErrCode SbMethod::Call( SbxValue* pRet, SbxVariable* pCaller )
// #100883 Own Broadcast for SbMethod // #100883 Own Broadcast for SbMethod
void SbMethod::Broadcast( SfxHintId nHintId ) 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 // Because the method could be called from outside, test here once again
// the authorisation // the authorisation
...@@ -2095,8 +2095,7 @@ void SbMethod::Broadcast( SfxHintId nHintId ) ...@@ -2095,8 +2095,7 @@ void SbMethod::Broadcast( SfxHintId nHintId )
pMod->Compile(); pMod->Compile();
// Block broadcasts while creating new method // Block broadcasts while creating new method
SfxBroadcaster* pSave = pCst; std::unique_ptr<SfxBroadcaster> pSaveBroadcaster = std::move(mpBroadcaster);
pCst = nullptr;
SbMethod* pThisCopy = new SbMethod( *this ); SbMethod* pThisCopy = new SbMethod( *this );
SbMethodRef xHolder = pThisCopy; SbMethodRef xHolder = pThisCopy;
if( mpPar.is() ) if( mpPar.is() )
...@@ -2108,14 +2107,14 @@ void SbMethod::Broadcast( SfxHintId nHintId ) ...@@ -2108,14 +2107,14 @@ void SbMethod::Broadcast( SfxHintId nHintId )
SetParameters( nullptr ); SetParameters( nullptr );
} }
pCst = pSave; mpBroadcaster = std::move(pSaveBroadcaster);
pSave->Broadcast( SbxHint( nHintId, pThisCopy ) ); mpBroadcaster->Broadcast( SbxHint( nHintId, pThisCopy ) );
SbxFlagBits nSaveFlags = GetFlags(); SbxFlagBits nSaveFlags = GetFlags();
SetFlag( SbxFlagBits::ReadWrite ); SetFlag( SbxFlagBits::ReadWrite );
pCst = nullptr; pSaveBroadcaster = std::move(mpBroadcaster);
Put( pThisCopy->GetValues_Impl() ); Put( pThisCopy->GetValues_Impl() );
pCst = pSave; mpBroadcaster = std::move(pSaveBroadcaster);
SetFlags( nSaveFlags ); SetFlags( nSaveFlags );
} }
} }
......
...@@ -56,7 +56,6 @@ class SbxVariableImpl ...@@ -56,7 +56,6 @@ class SbxVariableImpl
SbxVariable::SbxVariable() : SbxValue() SbxVariable::SbxVariable() : SbxValue()
{ {
pCst = nullptr;
pParent = nullptr; pParent = nullptr;
nUserData = 0; nUserData = 0;
nHash = 0; nHash = 0;
...@@ -78,7 +77,6 @@ SbxVariable::SbxVariable( const SbxVariable& r ) ...@@ -78,7 +77,6 @@ SbxVariable::SbxVariable( const SbxVariable& r )
} }
#endif #endif
} }
pCst = nullptr;
if( r.CanRead() ) if( r.CanRead() )
{ {
pParent = r.pParent; pParent = r.pParent;
...@@ -111,7 +109,6 @@ void SbxEnsureParentVariable::SetParent(SbxObject* p) ...@@ -111,7 +109,6 @@ void SbxEnsureParentVariable::SetParent(SbxObject* p)
SbxVariable::SbxVariable( SbxDataType t ) : SbxValue( t ) SbxVariable::SbxVariable( SbxDataType t ) : SbxValue( t )
{ {
pCst = nullptr;
pParent = nullptr; pParent = nullptr;
nUserData = 0; nUserData = 0;
nHash = 0; nHash = 0;
...@@ -125,18 +122,18 @@ SbxVariable::~SbxVariable() ...@@ -125,18 +122,18 @@ SbxVariable::~SbxVariable()
removeDimAsNewRecoverItem( this ); removeDimAsNewRecoverItem( this );
} }
#endif #endif
delete pCst; mpBroadcaster.reset();
} }
// Broadcasting // Broadcasting
SfxBroadcaster& SbxVariable::GetBroadcaster() SfxBroadcaster& SbxVariable::GetBroadcaster()
{ {
if( !pCst ) if( !mpBroadcaster )
{ {
pCst = new SfxBroadcaster; mpBroadcaster.reset( new SfxBroadcaster );
} }
return *pCst; return *mpBroadcaster;
} }
SbxArray* SbxVariable::GetParameters() const SbxArray* SbxVariable::GetParameters() const
...@@ -150,7 +147,7 @@ SbxArray* SbxVariable::GetParameters() const ...@@ -150,7 +147,7 @@ SbxArray* SbxVariable::GetParameters() const
void SbxVariable::Broadcast( SfxHintId nHintId ) 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 // Because the method could be called from outside, check the
// rights here again // rights here again
...@@ -174,8 +171,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) ...@@ -174,8 +171,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId )
SbxVariableRef aBroadcastGuard(this); SbxVariableRef aBroadcastGuard(this);
// Avoid further broadcasting // Avoid further broadcasting
SfxBroadcaster* pSave = pCst; std::unique_ptr<SfxBroadcaster> pSave = std::move(mpBroadcaster);
pCst = nullptr;
SbxFlagBits nSaveFlags = GetFlags(); SbxFlagBits nSaveFlags = GetFlags();
SetFlag( SbxFlagBits::ReadWrite ); SetFlag( SbxFlagBits::ReadWrite );
if( mpPar.is() ) if( mpPar.is() )
...@@ -184,8 +180,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId ) ...@@ -184,8 +180,7 @@ void SbxVariable::Broadcast( SfxHintId nHintId )
mpPar->GetRef( 0 ) = this; mpPar->GetRef( 0 ) = this;
} }
pSave->Broadcast( SbxHint( nHintId, this ) ); pSave->Broadcast( SbxHint( nHintId, this ) );
delete pCst; // who knows already, onto which thoughts someone comes? mpBroadcaster = std::move(pSave);
pCst = pSave;
SetFlags( nSaveFlags ); SetFlags( nSaveFlags );
} }
} }
......
...@@ -224,7 +224,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue ...@@ -224,7 +224,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue
friend class SbMethod; friend class SbMethod;
std::unique_ptr<SbxVariableImpl> mpImpl; // Impl data std::unique_ptr<SbxVariableImpl> mpImpl; // Impl data
SfxBroadcaster* pCst; // Broadcaster, if needed std::unique_ptr<SfxBroadcaster> mpBroadcaster; // Broadcaster, if needed
OUString maName; // Name, if available OUString maName; // Name, if available
SbxArrayRef mpPar; // Parameter-Array, if set SbxArrayRef mpPar; // Parameter-Array, if set
sal_uInt16 nHash; // Hash-ID for search sal_uInt16 nHash; // Hash-ID for search
...@@ -268,7 +268,7 @@ public: ...@@ -268,7 +268,7 @@ public:
// Sfx-Broadcasting-Support: // Sfx-Broadcasting-Support:
// Due to data reduction and better DLL-hierarchy currently via casting // Due to data reduction and better DLL-hierarchy currently via casting
SfxBroadcaster& GetBroadcaster(); SfxBroadcaster& GetBroadcaster();
bool IsBroadcaster() const { return pCst != nullptr; } bool IsBroadcaster() const { return mpBroadcaster != nullptr; }
virtual void Broadcast( SfxHintId nHintId ) override; virtual void Broadcast( SfxHintId nHintId ) override;
const SbxObject* GetParent() const { return pParent; } const SbxObject* GetParent() const { return pParent; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment