Kaydet (Commit) 263d7325 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in SbModule

Change-Id: I20525bd69c91ff35c9e569525a0d4556bc184982
üst 9653ac69
...@@ -626,8 +626,8 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule ) ...@@ -626,8 +626,8 @@ SbClassModuleObject::SbClassModuleObject( SbModule* pClassModule )
{ {
aOUSource = pClassModule->aOUSource; aOUSource = pClassModule->aOUSource;
aComment = pClassModule->aComment; aComment = pClassModule->aComment;
pImage = pClassModule->pImage; pImage = std::move(pClassModule->pImage);
pBreaks = pClassModule->pBreaks; pBreaks = std::move(pClassModule->pBreaks);
SetClassName( pClassModule->GetName() ); SetClassName( pClassModule->GetName() );
......
...@@ -461,9 +461,9 @@ SbModule::SbModule( const OUString& rName, bool bVBACompat ) ...@@ -461,9 +461,9 @@ SbModule::SbModule( const OUString& rName, bool bVBACompat )
SbModule::~SbModule() SbModule::~SbModule()
{ {
SAL_INFO("basic","Module named " << GetName() << " is destructing"); SAL_INFO("basic","Module named " << GetName() << " is destructing");
delete pImage; pImage.reset();
delete pBreaks; pBreaks.reset();
delete pClassData; pClassData.reset();
mxWrapper = nullptr; mxWrapper = nullptr;
} }
...@@ -492,7 +492,7 @@ const SbxObject* SbModule::FindType( const OUString& aTypeName ) const ...@@ -492,7 +492,7 @@ const SbxObject* SbModule::FindType( const OUString& aTypeName ) const
void SbModule::StartDefinitions() void SbModule::StartDefinitions()
{ {
delete pImage; pImage = nullptr; pImage.reset();
if( pClassData ) if( pClassData )
pClassData->clear(); pClassData->clear();
...@@ -642,7 +642,7 @@ void SbModule::EndDefinitions( bool bNewState ) ...@@ -642,7 +642,7 @@ void SbModule::EndDefinitions( bool bNewState )
void SbModule::Clear() void SbModule::Clear()
{ {
delete pImage; pImage = nullptr; pImage.reset();
if( pClassData ) if( pClassData )
pClassData->clear(); pClassData->clear();
SbxObject::Clear(); SbxObject::Clear();
...@@ -1524,7 +1524,7 @@ bool SbModule::SetBP( sal_uInt16 nLine ) ...@@ -1524,7 +1524,7 @@ bool SbModule::SetBP( sal_uInt16 nLine )
if( !IsBreakable( nLine ) ) if( !IsBreakable( nLine ) )
return false; return false;
if( !pBreaks ) if( !pBreaks )
pBreaks = new SbiBreakpoints; pBreaks.reset( new SbiBreakpoints );
size_t i; size_t i;
for( i = 0; i < pBreaks->size(); i++ ) for( i = 0; i < pBreaks->size(); i++ )
{ {
...@@ -1562,8 +1562,7 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) ...@@ -1562,8 +1562,7 @@ bool SbModule::ClearBP( sal_uInt16 nLine )
} }
if( pBreaks->empty() ) if( pBreaks->empty() )
{ {
delete pBreaks; pBreaks.reset();
pBreaks = nullptr;
} }
} }
return bRes; return bRes;
...@@ -1571,15 +1570,14 @@ bool SbModule::ClearBP( sal_uInt16 nLine ) ...@@ -1571,15 +1570,14 @@ bool SbModule::ClearBP( sal_uInt16 nLine )
void SbModule::ClearAllBP() void SbModule::ClearAllBP()
{ {
delete pBreaks; pBreaks.reset();
pBreaks = nullptr;
} }
void void
SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const SbModule::fixUpMethodStart( bool bCvtToLegacy, SbiImage* pImg ) const
{ {
if ( !pImg ) if ( !pImg )
pImg = pImage; pImg = pImage.get();
for( sal_uInt32 i = 0; i < pMethods->Count(); i++ ) for( sal_uInt32 i = 0; i < pMethods->Count(); i++ )
{ {
SbMethod* pMeth = dynamic_cast<SbMethod*>( pMethods->Get( static_cast<sal_uInt16>(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 ) ...@@ -1606,18 +1604,17 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer )
rStrm.ReadUChar( bImage ); rStrm.ReadUChar( bImage );
if( bImage ) if( bImage )
{ {
SbiImage* p = new SbiImage; std::unique_ptr<SbiImage> p( new SbiImage );
sal_uInt32 nImgVer = 0; sal_uInt32 nImgVer = 0;
if( !p->Load( rStrm, nImgVer ) ) if( !p->Load( rStrm, nImgVer ) )
{ {
delete p;
return false; return false;
} }
// If the image is in old format, we fix up the method start offsets // If the image is in old format, we fix up the method start offsets
if ( nImgVer < B_EXT_IMG_VERSION ) if ( nImgVer < B_EXT_IMG_VERSION )
{ {
fixUpMethodStart( false, p ); fixUpMethodStart( false, p.get() );
p->ReleaseLegacyBuffer(); p->ReleaseLegacyBuffer();
} }
aComment = p->aComment; aComment = p->aComment;
...@@ -1629,15 +1626,13 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer ) ...@@ -1629,15 +1626,13 @@ bool SbModule::LoadData( SvStream& rStrm, sal_uInt16 nVer )
if( nVer == 1 ) if( nVer == 1 )
{ {
SetSource32( p->aOUSource ); SetSource32( p->aOUSource );
delete p;
} }
else else
pImage = p; pImage = std::move(p);
} }
else else
{ {
SetSource32( p->aOUSource ); SetSource32( p->aOUSource );
delete p;
} }
} }
return true; return true;
......
...@@ -133,7 +133,7 @@ void SbiCodeGen::Save() ...@@ -133,7 +133,7 @@ void SbiCodeGen::Save()
if( pParser->IsCodeCompleting() ) if( pParser->IsCodeCompleting() )
return; return;
SbiImage* p = new SbiImage; std::unique_ptr<SbiImage> p( new SbiImage );
rMod.StartDefinitions(); rMod.StartDefinitions();
// OPTION BASE-Value: // OPTION BASE-Value:
p->nDimBase = pParser->nBase; p->nDimBase = pParser->nBase;
...@@ -150,7 +150,7 @@ void SbiCodeGen::Save() ...@@ -150,7 +150,7 @@ void SbiCodeGen::Save()
nIfaceCount = pParser->aIfaceVector.size(); nIfaceCount = pParser->aIfaceVector.size();
if( !rMod.pClassData ) if( !rMod.pClassData )
rMod.pClassData = new SbClassData; rMod.pClassData.reset( new SbClassData );
if( nIfaceCount ) if( nIfaceCount )
{ {
for( int i = 0 ; i < nIfaceCount ; i++ ) for( int i = 0 ; i < nIfaceCount ; i++ )
...@@ -375,11 +375,7 @@ void SbiCodeGen::Save() ...@@ -375,11 +375,7 @@ void SbiCodeGen::Save()
} }
if( !p->IsError() ) if( !p->IsError() )
{ {
rMod.pImage = p; rMod.pImage = std::move(p);
}
else
{
delete p;
} }
rMod.EndDefinitions(); rMod.EndDefinitions();
} }
......
...@@ -561,7 +561,7 @@ SbMethod* SbiInstance::GetCaller( sal_uInt16 nLevel ) ...@@ -561,7 +561,7 @@ SbMethod* SbiInstance::GetCaller( sal_uInt16 nLevel )
SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart ) SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
: rBasic( *static_cast<StarBASIC*>(pm->pParent) ), pInst( GetSbData()->pInst ), : 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; nFlags = pe ? pe->GetDebugFlags() : BasicDebugFlags::NONE;
pIosys = pInst->GetIoSystem(); pIosys = pInst->GetIoSystem();
...@@ -3149,10 +3149,9 @@ bool SbiRuntime::implIsClass( SbxObject const * pObj, const OUString& aClass ) ...@@ -3149,10 +3149,9 @@ bool SbiRuntime::implIsClass( SbxObject const * pObj, const OUString& aClass )
{ {
OUString aObjClass = pObj->GetClassName(); OUString aObjClass = pObj->GetClassName();
SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass ); SbModule* pClassMod = GetSbData()->pClassFac->FindClass( aObjClass );
SbClassData* pClassData; if( pClassMod && pClassMod->pClassData )
if( pClassMod && (pClassData=pClassMod->pClassData) != nullptr )
{ {
SbxVariable* pClassVar = pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare ); SbxVariable* pClassVar = pClassMod->pClassData->mxIfaces->Find( aClass, SbxClassType::DontCare );
bRet = (pClassVar != nullptr); bRet = (pClassVar != nullptr);
} }
} }
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <vector> #include <vector>
#include <deque> #include <deque>
#include <memory>
#include <basic/basicdllapi.h> #include <basic/basicdllapi.h>
#include <basic/codecompletecache.hxx> #include <basic/codecompletecache.hxx>
...@@ -62,9 +63,9 @@ protected: ...@@ -62,9 +63,9 @@ protected:
css::uno::Reference< css::script::XInvocation > mxWrapper; css::uno::Reference< css::script::XInvocation > mxWrapper;
OUString aOUSource; OUString aOUSource;
OUString aComment; OUString aComment;
SbiImage* pImage; // the Image std::unique_ptr<SbiImage> pImage; // the Image
SbiBreakpoints* pBreaks; // Breakpoints std::unique_ptr<SbiBreakpoints> pBreaks; // Breakpoints
SbClassData* pClassData; std::unique_ptr<SbClassData> pClassData;
bool mbVBACompat; bool mbVBACompat;
sal_Int32 mnType; sal_Int32 mnType;
SbxObjectRef pDocObject; // an impl object ( used by Document Modules ) SbxObjectRef pDocObject; // an impl object ( used by Document Modules )
......
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