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 )
{
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() );
......
......@@ -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;
......
......@@ -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();
}
......
......@@ -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);
}
}
......
......@@ -28,6 +28,7 @@
#include <rtl/ustring.hxx>
#include <vector>
#include <deque>
#include <memory>
#include <basic/basicdllapi.h>
#include <basic/codecompletecache.hxx>
......@@ -62,9 +63,9 @@ protected:
css::uno::Reference< css::script::XInvocation > mxWrapper;
OUString aOUSource;
OUString aComment;
SbiImage* pImage; // the Image
SbiBreakpoints* pBreaks; // Breakpoints
SbClassData* pClassData;
std::unique_ptr<SbiImage> pImage; // the Image
std::unique_ptr<SbiBreakpoints> pBreaks; // Breakpoints
std::unique_ptr<SbClassData> pClassData;
bool mbVBACompat;
sal_Int32 mnType;
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