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 )
// #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 );
}
}
......
......@@ -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 );
}
}
......
......@@ -224,7 +224,7 @@ class BASIC_DLLPUBLIC SbxVariable : public SbxValue
friend class SbMethod;
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
SbxArrayRef mpPar; // Parameter-Array, if set
sal_uInt16 nHash; // Hash-ID for search
......@@ -268,7 +268,7 @@ public:
// Sfx-Broadcasting-Support:
// Due to data reduction and better DLL-hierarchy currently via casting
SfxBroadcaster& GetBroadcaster();
bool IsBroadcaster() const { return pCst != nullptr; }
bool IsBroadcaster() const { return mpBroadcaster != nullptr; }
virtual void Broadcast( SfxHintId nHintId ) override;
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