diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-26 12:06:27 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-26 13:30:49 +0200 |
commit | 4054dff516367b332b7e3ce6fa91a452bf690571 (patch) | |
tree | 74ce35623e84933e4da9b134855ac1c74c4bce1d /editeng | |
parent | c0cc59adca23580864a2e5cdadf66212246cbfcc (diff) |
use unique_ptr when Clone()'ing PoolItems
and fix a handful of small leaks in the process
Change-Id: I876e12ff5305f9dda84532d4182fb91657d6fa0c
Reviewed-on: https://gerrit.libreoffice.org/62389
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 3 | ||||
-rw-r--r-- | editeng/source/editeng/impedit4.cxx | 3 | ||||
-rw-r--r-- | editeng/source/uno/unoipset.cxx | 3 |
3 files changed, 3 insertions, 6 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index f4c761183276..18d14cf82d81 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -896,11 +896,10 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map MapUnit eDestUnit = pDestUnit ? *pDestUnit : pDestPool->GetMetric( nWhich ); if ( eSourceUnit != eDestUnit ) { - SfxPoolItem* pItem = rSource.Get( nSourceWhich ).Clone(); + std::unique_ptr<SfxPoolItem> pItem(rSource.Get( nSourceWhich ).Clone()); ConvertItem( *pItem, eSourceUnit, eDestUnit ); pItem->SetWhich(nWhich); rDest.Put( *pItem ); - delete pItem; } else { diff --git a/editeng/source/editeng/impedit4.cxx b/editeng/source/editeng/impedit4.cxx index 4be47ec63d4a..68de66939b06 100644 --- a/editeng/source/editeng/impedit4.cxx +++ b/editeng/source/editeng/impedit4.cxx @@ -1237,10 +1237,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); else { - SfxPoolItem* pNew = rX.GetItem()->Clone(); + std::unique_ptr<SfxPoolItem> pNew(rX.GetItem()->Clone()); ConvertItem( *pNew, eSourceUnit, eDestUnit ); pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos ); - delete pNew; } DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (1)" ); aPaM.GetNode()->GetCharAttribs().InsertAttrib( pAttr ); diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx index 1f84b114a810..71afb18871e3 100644 --- a/editeng/source/uno/unoipset.cxx +++ b/editeng/source/uno/unoipset.cxx @@ -171,7 +171,7 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa SvxUnoConvertFromMM( eMapUnit, aValue ); } - SfxPoolItem *pNewItem = pItem->Clone(); + std::unique_ptr<SfxPoolItem> pNewItem( pItem->Clone() ); sal_uInt8 nMemberId = pMap->nMemberId; if( eMapUnit == MapUnit::Map100thMM ) @@ -183,7 +183,6 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa pNewItem->SetWhich( pMap->nWID ); rSet.Put( *pNewItem ); } - delete pNewItem; } } |