sc/source/ui/view/viewfunc.cxx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
New commits: commit b02f05981ffe837b94d4a437c32ea1f9b7b7c883 Author: Jan-Marek Glogowski <[email protected]> Date: Thu Apr 6 14:21:06 2017 +0200 loplugin:useuniqueptr for ScViewFunc::InsertName Change-Id: Idf0b08a86f9b8043b3b886a0b15b2ac0fbb905fb Reviewed-on: https://gerrit.libreoffice.org/36209 Tested-by: Jenkins <[email protected]> Reviewed-by: Stephan Bergmann <[email protected]> diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 43d661a12f2a..ef742edc5478 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -2663,9 +2663,9 @@ bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol, ScRangeName* pList = rDoc.GetRangeName(); ScRangeData::Type nType = ScRangeData::Type::Name; - ScRangeData* pNewEntry = new ScRangeData( &rDoc, rName, rSymbol, - ScAddress( GetViewData().GetCurX(), GetViewData().GetCurY(), - nTab), nType ); + std::unique_ptr<ScRangeData> pNewEntry(new ScRangeData( + &rDoc, rName, rSymbol, ScAddress( GetViewData().GetCurX(), + GetViewData().GetCurY(), nTab), nType )); OUString aUpType = rType.toAsciiUpperCase(); if ( aUpType.indexOf( 'P' ) != -1 ) nType |= ScRangeData::Type::PrintArea; @@ -2691,9 +2691,9 @@ bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol, pList->erase(*pData); } - if ( pList->insert( pNewEntry ) ) + // don't delete, insert took ownership, even on failure! + if ( pList->insert( pNewEntry.release() ) ) bOk = true; - pNewEntry = nullptr; // never delete, insert took ownership rDoc.CompileHybridFormula(); @@ -2701,7 +2701,6 @@ bool ScViewFunc::InsertName( const OUString& rName, const OUString& rSymbol, SfxGetpApp()->Broadcast( SfxHint( SfxHintId::ScAreasChanged ) ); } - delete pNewEntry; // if it wasn't inserted return bOk; } _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
