summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2018-10-30 10:41:54 +0100
committerJan-Marek Glogowski <glogow@fbihome.de>2018-10-30 21:40:26 +0100
commit2226d69ae3f416c15f3718f43a05055091ea50d2 (patch)
treeb06ac43328b8c8c2ef56b67a086a71fdb65fce9e /basic
parentc2a9207e28c11132d5c3d4817c8a903a3f38ecd1 (diff)
Make SbiProcDef::Match more readable
This reverts commit 02caaef29d60 ("loplugin:useuniqueptr in SbiProcDef") and is hopefully easier to follow. Change-Id: I46be2b3c7a933743795d89fe17a2c499c6983382 Reviewed-on: https://gerrit.libreoffice.org/62548 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com> Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/dim.cxx4
-rw-r--r--basic/source/comp/symtbl.cxx12
-rw-r--r--basic/source/inc/symtbl.hxx2
3 files changed, 11 insertions, 7 deletions
diff --git a/basic/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 3a984ce8c824..dc6bf5260448 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -1032,7 +1032,7 @@ void SbiParser::DefDeclare( bool bPrivate )
}
else
{
- pDef->Match( std::unique_ptr<SbiProcDef>(p) );
+ pDef->Match( p );
}
}
else
@@ -1214,7 +1214,7 @@ void SbiParser::DefProc( bool bStatic, bool bPrivate )
}
}
- pDef->Match( std::unique_ptr<SbiProcDef>(pProc) );
+ pDef->Match( pProc );
}
else
{
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index 2002f3fce278..351cdaa818e5 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -409,7 +409,7 @@ void SbiProcDef::SetType( SbxDataType t )
// if the match is OK, pOld is replaced by this in the pool
// pOld is deleted in any case!
-void SbiProcDef::Match( std::unique_ptr<SbiProcDef> pOld )
+void SbiProcDef::Match( SbiProcDef* pOld )
{
SbiSymDef *pn=nullptr;
// parameter 0 is the function name
@@ -433,16 +433,20 @@ void SbiProcDef::Match( std::unique_ptr<SbiProcDef> pOld )
pOld->pIn->GetParser()->SetCol1( 0 );
pOld->pIn->GetParser()->Error( ERRCODE_BASIC_BAD_DECLARATION, aName );
}
+
if( !pIn && pOld->pIn )
{
// Replace old entry with the new one
nPos = pOld->nPos;
nId = pOld->nId;
pIn = pOld->pIn;
- std::unique_ptr<SbiSymDef> tmp(this);
- std::swap(pIn->m_Data[nPos], tmp);
- (void)tmp.release();
+
+ // don't delete pOld twice, if it's stored in m_Data
+ if (pOld == pIn->m_Data[nPos].get())
+ pOld = nullptr;
+ pIn->m_Data[nPos].reset(this);
}
+ delete pOld;
}
void SbiProcDef::setPropertyMode( PropertyMode ePropMode )
diff --git a/basic/source/inc/symtbl.hxx b/basic/source/inc/symtbl.hxx
index 3c0f9bf0128e..64a11ea814f3 100644
--- a/basic/source/inc/symtbl.hxx
+++ b/basic/source/inc/symtbl.hxx
@@ -194,7 +194,7 @@ public:
// Match with a forward-declaration. The parameter names are
// compared and the forward declaration is replaced by this
- void Match( std::unique_ptr<SbiProcDef> pForward );
+ void Match( SbiProcDef* pForward );
private:
SbiProcDef( const SbiProcDef& ) = delete;