diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-16 14:41:21 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-01-19 08:58:46 +0200 |
commit | 263d7325691f4b0a1bda155f1c53bbcf712e9f09 (patch) | |
tree | 024ca8d5fd98d09053faa6c4b22afb91098890d2 /basic | |
parent | 9653ac69f8c9fdfcd353a1b15c701139dd541e9b (diff) |
loplugin:useuniqueptr in SbModule
Change-Id: I20525bd69c91ff35c9e569525a0d4556bc184982
Diffstat (limited to 'basic')
-rw-r--r-- | basic/source/classes/sb.cxx | 4 | ||||
-rw-r--r-- | basic/source/classes/sbxmod.cxx | 29 | ||||
-rw-r--r-- | basic/source/comp/codegen.cxx | 10 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 7 |
4 files changed, 20 insertions, 30 deletions
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 85ea6d902ec1..6562a3fc9d69 100644 --- a/basic/source/classes/sb.cxx +++ b/basic/source/classes/sb.cxx @@ -626,8 +626,8 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) { aOUSource = pClassModule->aOUSource; aComment = pClassModule->aComment; - pImage = pClassModule->pImage; - pBreaks = pClassModule->pBreaks; + pImage = std::move(pClassModule->pImage); + pBreaks = std::move(pClassModule->pBreaks); SetClassName( pClassModule->GetName() ); diff --git a/basic/source/classes/sbxmod.cxx b/basic/source/classes/sbxmod.cxx index d83cd2b59874..de486209750a 100644 --- a/basic/source/classes/sbxmod.cxx +++ b/basic/source/classes/sbxmod.cxx @@ -461,9 +461,9 @@ SbModule::SbModule( const OUString& rName, bool bVBACompat ) SbModule::~SbModule() { SAL_INFO("basic","Module named " << GetName() << " is destructing"); - delete pImage; - delete pBreaks; - delete pClassData; + pImage.reset(); + pBreaks.reset(); + pClassData.reset(); mxWrapper = nullptr; } @@ -492,7 +492,7 @@ const SbxObject* SbModule::FindType( const OUString& aTypeName ) const void SbModule::StartDefinitions() { - delete pImage; pImage = nullptr; + pImage.reset(); if( pClassData ) pClassData->clear(); @@ -642,7 +642,7 @@ void SbModule::EndDefinitions( bool bNewState ) void SbModule::Clear() { - delete pImage; pImage = nullptr; + pImage.reset(); if( pClassData ) pClassData->clear(); SbxObject::Clear(); @@ -1524,7 +1524,7 @@ bool SbModule::SetBP( sal_uInt16 nLine ) if( !IsBreakable( nLine ) ) return false; if( !pBreaks ) - pBreaks = new SbiBreakpoints; + pBreaks.reset( new SbiBreakpoints ); size_t i; for( i = 0; i < pBreaks->size(); i++ ) { @@ -1562,8 +1562,7 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) } if( pBreaks->empty() ) { - delete pBreaks; - pBreaks = nullptr; + pBreaks.reset(); } } return bRes; @@ -1571,15 +1570,14 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) void SbModule::ClearAllBP() { - delete pBreaks; - pBreaks = nullptr; + pBreaks.reset(); } void SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const { if ( !pImg ) - pImg = pImage; + pImg = pImage.get(); for( sal_uInt32 i = 0; i < pMethods->Count(); i++ ) { SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( static_cast<sal_uInt16>(i) ) ); @@ -1606,18 +1604,17 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) rStrm.ReadUChar( bImage ); if( bImage ) { - SbiImage* p = new SbiImage; + std::unique_ptr<SbiImage> p( new SbiImage ); sal_uInt32 nImgVer = 0; if( !p->Load( rStrm, nImgVer ) ) { - delete p; return false; } // If the image is in old format, we fix up the method start offsets if ( nImgVer < B_EXT_IMG_VERSION ) { - fixUpMethodStart( false, p ); + fixUpMethodStart( false, p.get() ); p->ReleaseLegacyBuffer(); } aComment = p->aComment; @@ -1629,15 +1626,13 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) if( nVer == 1 ) { SetSource32( p->aOUSource ); - delete p; } else - pImage = p; + pImage = std::move(p); } else { SetSource32( p->aOUSource ); - delete p; } } return true; diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx index aa587ba0e5b5..8b7a0a8142e4 100644 --- a/basic/source/comp/codegen.cxx +++ b/basic/source/comp/codegen.cxx @@ -133,7 +133,7 @@ void SbiCodeGen::Save() if( pParser->IsCodeCompleting() ) return; - SbiImage* p = new SbiImage; + std::unique_ptr<SbiImage> p( new SbiImage ); rMod.StartDefinitions(); // OPTION BASE-Value: p->nDimBase = pParser->nBase; @@ -150,7 +150,7 @@ void SbiCodeGen::Save() nIfaceCount = pParser->aIfaceVector.size(); if( !rMod.pClassData ) - rMod.pClassData = new SbClassData; + rMod.pClassData.reset( new SbClassData ); if( nIfaceCount ) { for( int i = 0 ; i < nIfaceCount ; i++ ) @@ -375,11 +375,7 @@ void SbiCodeGen::Save() } if( !p->IsError() ) { - rMod.pImage = p; - } - else - { - delete p; + rMod.pImage = std::move(p); } rMod.EndDefinitions(); } diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index db68c4988f98..4c2b52d1ca81 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -561,7 +561,7 @@ SbMethod* SbiInstance::GetCaller( sal_uInt16 nLevel ) SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart ) : rBasic( *static_cast<StarBASIC*>(pm->pParent) ), pInst( GetSbData()->pInst ), - pMod( pm ), pMeth( pe ), pImg( pMod->pImage ), mpExtCaller(nullptr), m_nLastTime(0) + pMod( pm ), pMeth( pe ), pImg( pMod->pImage.get() ), mpExtCaller(nullptr), m_nLastTime(0) { nFlags = pe ? pe->GetDebugFlags() : BasicDebugFlags::NONE; pIosys = pInst->GetIoSystem(); @@ -3149,10 +3149,9 @@ bool SbiRuntime::implIsClass( SbxObject const * pObj, const OUString& aClass ) { OUString aObjClass = pObj->GetClassName(); SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass ); - SbClassData* pClassData; - if( pClassMod && (pClassData=pClassMod->pClassData) != nullptr ) + if( pClassMod && pClassMod->pClassData ) { - SbxVariable* pClassVar = pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare ); + SbxVariable* pClassVar = pClassMod->pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare ); bRet = (pClassVar != nullptr); } } |