diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-04 18:58:58 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2024-07-05 08:59:49 +0200 |
commit | 269654fe179384f994bf0fe47e2af8c731cac377 (patch) | |
tree | 4df3dfed469eedcb823d32fd754624d04b28dea4 /svl | |
parent | 07a166790b6c6c0b0bce96ce25d970a636ba55d6 (diff) |
fix asan build
after commit 85fd526fc681a994415bb422090d1d23aa7d54f6
"fix and simplify the ItemInstanceManager mechanism"
The problem is that some *Item classes in sw/ and sc/
share WhichIds, and a whole bunch of SfxBoolItem
subclasses share the same SfxItemType enum value.
So we ended up mixing and matching objects
of different concrete subclasses in a given
*ItemManager collection.
Add some asserts to the global pool code to catch
issues like this earlier on.
Add unique value of the SfxItemType enum for all
the SfxBoolItem subclasses
Change-Id: I3c8d4e02be1cd412b0292e973a6498df5f8e7102
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/170003
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/globalpool.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/svl/source/items/globalpool.cxx b/svl/source/items/globalpool.cxx index 7ad6abc6a49f..313db586a566 100644 --- a/svl/source/items/globalpool.cxx +++ b/svl/source/items/globalpool.cxx @@ -283,6 +283,11 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS const SfxPoolItem* pAlternative = rItemManager.find(*pSource); if (pAlternative) { + SAL_WARN_IF(typeid(*pAlternative) != typeid(*pSource), "svl", + "wrong item from pool, expected " << typeid(*pSource).name() + << " but got " + << typeid(*pAlternative).name()); + assert(typeid(*pAlternative) == typeid(*pSource) && "wrong item from pool"); // Here we do *not* need to check if it is an SfxSetItem // and cannot be shared if they are in/use another pool: // The SfxItemSet::operator== will check for SfxItemPools @@ -324,10 +329,15 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS // bPassingOwnership is given just use the item, else clone it if (!bPassingOwnership) { + auto pPreviousSource = pSource; pSource = pSource->Clone(pMasterPool); #ifdef DBG_UTIL assert(pSource->Which() == nWhich && "ITEM: Clone of Item did NOT copy/set WhichID (!)"); #endif + SAL_WARN_IF(typeid(*pPreviousSource) != typeid(*pSource), "svl", + "wrong item from Clone(), expected " << typeid(*pPreviousSource).name() + << " but got " << typeid(*pSource).name()); + assert(typeid(*pPreviousSource) == typeid(*pSource) && "wrong item from Clone()"); } // increase RefCnt 0->1 |