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 /sc | |
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 'sc')
-rw-r--r-- | sc/source/core/data/attarray.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/unoobj/afmtuno.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/defltuno.cxx | 3 |
3 files changed, 5 insertions, 10 deletions
diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index e5c3f3534e55..16201a96b22b 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -746,9 +746,9 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, SCROW nY1 = nStart; SCROW nY2 = mvData[nPos].nEndRow; - SvxBoxItem* pNewBoxItem = pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr; - SvxLineItem* pNewTLBRItem = pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr; - SvxLineItem* pNewBLTRItem = pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr; + std::unique_ptr<SvxBoxItem> pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr); + std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr); + std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr); // fetch line and update attributes with parameters @@ -823,9 +823,6 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, else nPos++; } - delete pNewBoxItem; - delete pNewTLBRItem; - delete pNewBLTRItem; } else { diff --git a/sc/source/ui/unoobj/afmtuno.cxx b/sc/source/ui/unoobj/afmtuno.cxx index d2f03486c794..1aff21e72fdb 100644 --- a/sc/source/ui/unoobj/afmtuno.cxx +++ b/sc/source/ui/unoobj/afmtuno.cxx @@ -659,11 +659,10 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue( } break; default: - SfxPoolItem* pNewItem = pItem->Clone(); + std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone()); bDone = pNewItem->PutValue( aValue, pEntry->nMemberId ); if (bDone) pData->PutItem( nFieldIndex, *pNewItem ); - delete pNewItem; } if (bDone) diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 87867b79f929..bec8a82e0429 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -186,13 +186,12 @@ void SAL_CALL ScDocDefaultsObj::setPropertyValue( else { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); - SfxPoolItem* pNewItem = pPool->GetDefaultItem(pEntry->nWID).Clone(); + std::unique_ptr<SfxPoolItem> pNewItem(pPool->GetDefaultItem(pEntry->nWID).Clone()); if( !pNewItem->PutValue( aValue, pEntry->nMemberId ) ) throw lang::IllegalArgumentException(); pPool->SetPoolDefaultItem( *pNewItem ); - delete pNewItem; // copied in SetPoolDefaultItem ItemsChanged(); } |