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 /forms | |
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 'forms')
-rw-r--r-- | forms/source/richtext/richtextimplcontrol.cxx | 3 | ||||
-rw-r--r-- | forms/source/richtext/rtattributehandler.cxx | 8 |
2 files changed, 4 insertions, 7 deletions
diff --git a/forms/source/richtext/richtextimplcontrol.cxx b/forms/source/richtext/richtextimplcontrol.cxx index 4ab753f040c7..5eec237ff775 100644 --- a/forms/source/richtext/richtextimplcontrol.cxx +++ b/forms/source/richtext/richtextimplcontrol.cxx @@ -225,10 +225,9 @@ namespace frm WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhich( _rScriptSetItem.Which() ); if ( pNormalizedItem ) { - SfxPoolItem* pProperWhich = pNormalizedItem->Clone(); + std::unique_ptr<SfxPoolItem> pProperWhich(pNormalizedItem->Clone()); pProperWhich->SetWhich( nNormalizedWhichId ); _rScriptSetItem.GetItemSet().Put( *pProperWhich ); - DELETEZ( pProperWhich ); } else _rScriptSetItem.GetItemSet().InvalidateItem( nNormalizedWhichId ); diff --git a/forms/source/richtext/rtattributehandler.cxx b/forms/source/richtext/rtattributehandler.cxx index c78e3524bb04..7c2845e9b34f 100644 --- a/forms/source/richtext/rtattributehandler.cxx +++ b/forms/source/richtext/rtattributehandler.cxx @@ -281,7 +281,7 @@ namespace frm const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() ); if ( pItem ) - aState.setItem( pItem->Clone() ); + aState.setItem( pItem ); return aState; } @@ -291,14 +291,13 @@ namespace frm { if ( _pAdditionalArg ) { - SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone(); + std::unique_ptr<SfxPoolItem> pCorrectWich(_pAdditionalArg->Clone()); pCorrectWich->SetWhich( getWhich() ); if ( m_bScriptDependent ) putItemForScript( _rNewAttribs, *pCorrectWich, _nForScriptType ); else _rNewAttribs.Put( *pCorrectWich ); - DELETEZ( pCorrectWich ); } else OSL_FAIL( "SlotHandler::executeAttribute: need attributes to do something!" ); @@ -434,10 +433,9 @@ namespace frm OSL_ENSURE( dynamic_cast<const SfxBoolItem*>( _pAdditionalArg) != nullptr, "BooleanHandler::executeAttribute: invalid argument!" ); if ( _pAdditionalArg ) { - SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone(); + std::unique_ptr<SfxPoolItem> pCorrectWich(_pAdditionalArg->Clone()); pCorrectWich->SetWhich( getWhich() ); _rNewAttribs.Put( *pCorrectWich ); - DELETEZ( pCorrectWich ); } } |