From c969f04f72b95c5d3a1fdd3cf8190826bab440c2 Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 29 Oct 2018 14:27:04 +0200 Subject: loplugin:useuniqueptr in SfxItemPoolCache::ApplyTo Change-Id: Ica6ffb5bbaad5c941c65cae02bba7ea2380646f3 Reviewed-on: https://gerrit.libreoffice.org/62652 Tested-by: Jenkins Reviewed-by: Noel Grandin --- svl/source/items/poolcach.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'svl/source/items/poolcach.cxx') diff --git a/svl/source/items/poolcach.cxx b/svl/source/items/poolcach.cxx index c43d1d50973e..f9e29a7879a5 100644 --- a/svl/source/items/poolcach.cxx +++ b/svl/source/items/poolcach.cxx @@ -78,7 +78,7 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem ) } // Insert the new attributes in a new Set - SfxSetItem *pNewItem = static_cast(rOrigItem.Clone()); + std::unique_ptr pNewItem(static_cast(rOrigItem.Clone())); if ( pItemToPut ) { pNewItem->GetItemSet().PutDirect( *pItemToPut ); @@ -88,8 +88,8 @@ const SfxSetItem& SfxItemPoolCache::ApplyTo( const SfxSetItem &rOrigItem ) else pNewItem->GetItemSet().Put( *pSetToPut ); const SfxSetItem* pNewPoolItem = static_cast(&pPool->Put( *pNewItem )); - DBG_ASSERT( pNewPoolItem != pNewItem, "Pool: same in and out?" ); - delete pNewItem; + DBG_ASSERT( pNewPoolItem != pNewItem.get(), "Pool: same in and out?" ); + pNewItem.reset(); // Adapt refcount; one each for the cache pNewPoolItem->AddRef( pNewPoolItem != &rOrigItem ? 2 : 1 ); -- cgit