summaryrefslogtreecommitdiffstats
path: root/svl
diff options
context:
space:
mode:
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itempool.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index 11be19bc62e0..8df891a247f5 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -631,17 +631,15 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
}
}
+ const SfxPoolItem* pFoundItem = nullptr;
// 2. search for an item with matching attributes.
if (rItem.IsSortable())
{
- auto pFoundItem = rItemArr.findByLessThan(&rItem);
+ pFoundItem = rItemArr.findByLessThan(&rItem);
if (pFoundItem)
{
assert(*pFoundItem == rItem);
AddRef(*pFoundItem);
- if (bPassingOwnership)
- delete &rItem;
- return *pFoundItem;
}
}
else
@@ -650,12 +648,20 @@ const SfxPoolItem& SfxItemPool::PutImpl( const SfxPoolItem& rItem, sal_uInt16 nW
{
if (**itr == rItem)
{
- AddRef(**itr);
+ pFoundItem = *itr;
assert((!bPassingOwnership || (&rItem != *itr)) && "can't be passing ownership and have the item already in the pool");
- return **itr;
+ AddRef(**itr);
+ break;
}
}
}
+
+ if (pFoundItem)
+ {
+ if (bPassingOwnership)
+ delete &rItem;
+ return *pFoundItem;
+ }
}
// 3. not found, so clone to insert into the pointer array.