[Libreoffice-commits] core.git: basic/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Oct 30 20:40:50 UTC 2018
basic/source/comp/dim.cxx | 4 ++--
basic/source/comp/symtbl.cxx | 12 ++++++++----
basic/source/inc/symtbl.hxx | 2 +-
3 files changed, 11 insertions(+), 7 deletions(-)
New commits:
commit 2226d69ae3f416c15f3718f43a05055091ea50d2
Author: Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Tue Oct 30 10:41:54 2018 +0100
Commit: Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Oct 30 21:40:26 2018 +0100
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 at collabora.co.uk>
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>
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;
More information about the Libreoffice-commits
mailing list