summaryrefslogtreecommitdiff
path: root/svl
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2024-02-15 19:14:42 +0100
committerArmin Le Grand <Armin.Le.Grand@me.com>2024-02-16 17:05:59 +0100
commit3c3270c3527ce5bb7653727bc7749e4d58ba64cc (patch)
treec83d1b25d3ad591e78557d935d6e8997758701d0 /svl
parente86c6423d6ec9641dcc2ea3748d74759cd8e67fe (diff)
ITEM: Better test for DynamicDefaultItems
Change-Id: Ie18f18655e4ee9ca70580b540678003a12b0465d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163458 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'svl')
-rw-r--r--svl/source/items/itemset.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 05ba5672a02c..56cde0aec56c 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -499,13 +499,6 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
// static default Items can just be used without RefCounting
return pSource;
- if (pSource->isDynamicDefault()
- && pSource->isSetItem()
- && static_cast<const SfxSetItem*>(pSource)->GetItemSet().GetPool() == &rPool)
- // only use without RefCounting when SfxSetItem and the Pool is correct.
- // all other cases just clone (as before)
- return pSource;
-
if (0 == pSource->Which())
{
// There should be no Items with 0 == WhichID, but there are some
@@ -516,6 +509,14 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* pS
return pSource->Clone();
}
+ if (pSource->isDynamicDefault() && rPool.GetPoolDefaultItem(pSource->Which()) == pSource)
+ // dynamic defaults are not allowed to 'leave' the Pool they are
+ // defined for. We can check by comparing the PoolDefault (the
+ // PoolDefaultItem) to pSource by ptr compare (instance). When
+ // same Item we can use without RefCount. Else it will be cloned
+ // below the standard way.
+ return pSource;
+
#ifdef DBG_UTIL
// remember WhichID due to being able to assert Clone() error(s)
const sal_uInt16 nWhich(pSource->Which());