diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2017-04-06 14:21:06 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-06 13:25:56 +0000 |
commit | b02f05981ffe837b94d4a437c32ea1f9b7b7c883 (patch) | |
tree | 9dd589a349da0c95b8a8762046e7de2a8f42eefb /sc | |
parent | fb2cd383f7b540b948565ef6e299a4cd5e125e2d (diff) |
loplugin:useuniqueptr for ScViewFunc::InsertName
Change-Id: Idf0b08a86f9b8043b3b886a0b15b2ac0fbb905fb
Reviewed-on: https://gerrit.libreoffice.org/36209
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/view/viewfunc.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
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; } |