Kaydet (Commit) 668de126 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

improve assert in SfxItemPooL::Put

need to check for ownership passing in both variants of the loop, so
just move it into the common block below.

Change-Id: I75929377dd64df722a8ef040b5f714346417475d
Reviewed-on: https://gerrit.libreoffice.org/71826
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d6e8e41c
...@@ -620,9 +620,8 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW ...@@ -620,9 +620,8 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
// if is already in a pool, then it is worth checking if it is in this one. // if is already in a pool, then it is worth checking if it is in this one.
if ( IsPooledItem(&rItem) ) if ( IsPooledItem(&rItem) )
{ {
auto it = rItemArr.find(const_cast<SfxPoolItem *>(&rItem));
// 1. search for an identical pointer in the pool // 1. search for an identical pointer in the pool
auto it = rItemArr.find(const_cast<SfxPoolItem *>(&rItem));
if (it != rItemArr.end()) if (it != rItemArr.end())
{ {
AddRef(rItem); AddRef(rItem);
...@@ -637,10 +636,7 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW ...@@ -637,10 +636,7 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
{ {
pFoundItem = rItemArr.findByLessThan(&rItem); pFoundItem = rItemArr.findByLessThan(&rItem);
if (pFoundItem) if (pFoundItem)
{
assert(*pFoundItem == rItem); assert(*pFoundItem == rItem);
AddRef(*pFoundItem);
}
} }
else else
{ {
...@@ -649,15 +645,14 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW ...@@ -649,15 +645,14 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
if (**itr == rItem) if (**itr == rItem)
{ {
pFoundItem = *itr; pFoundItem = *itr;
assert((!bPassingOwnership || (&rItem != *itr)) && "can't be passing ownership and have the item already in the pool");
AddRef(**itr);
break; break;
} }
} }
} }
if (pFoundItem) if (pFoundItem)
{ {
assert((!bPassingOwnership || (&rItem != pFoundItem)) && "can't be passing ownership and have the item already in the pool");
AddRef(*pFoundItem);
if (bPassingOwnership) if (bPassingOwnership)
delete &rItem; delete &rItem;
return *pFoundItem; return *pFoundItem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment