svl/source/items/itemset.cxx |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

New commits:
commit fcb7bb06bdef712cf59874a60e6dd105ac452596
Author:     Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de>
AuthorDate: Fri Sep 13 11:33:49 2024 +0200
Commit:     Armin Le Grand <armin.le.gr...@me.com>
CommitDate: Fri Sep 13 16:27:42 2024 +0200

    ITEM: adapt SfxPoolItemHolder::operator=
    
    I formally tried to avoid un/re-register if Item needs
    surrogate support, but there are more aspects to this,
    e.g. the pool could be different or even the WhichID
    of the Item, so just do the necessary here. These cases
    are also not too often used.
    
    Change-Id: I8d1e8854f5ce3cac5566c076797162ba2e4b4b75
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173329
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <armin.le.gr...@me.com>

diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index e580653acb4e..d9da9c093cc9 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -178,10 +178,8 @@ const SfxPoolItemHolder& 
SfxPoolItemHolder::operator=(const SfxPoolItemHolder& r
     if (this == &rHolder || *this == rHolder)
         return *this;
 
-    // avoid unnecessary unregister/register actions
-    const bool bWasRegistered(nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()));
-    const bool bWillBeRegistered(nullptr != rHolder.m_pItem && 
rHolder.getPool().NeedsSurrogateSupport(rHolder.m_pItem->Which()));
-    SfxItemPool* pOldPool(m_pPool);
+    if (nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()))
+        getPool().unregisterPoolItemHolder(*this);
 
     if (nullptr != m_pItem)
         implCleanupItemEntry(m_pItem);
@@ -192,14 +190,8 @@ const SfxPoolItemHolder& 
SfxPoolItemHolder::operator=(const SfxPoolItemHolder& r
     if (nullptr != m_pItem)
         m_pItem = implCreateItemEntry(getPool(), m_pItem, false);
 
-    if (bWasRegistered != bWillBeRegistered)
-    {
-        // adapt registration if needed
-        if (bWillBeRegistered)
-            getPool().registerPoolItemHolder(*this);
-        else
-            pOldPool->unregisterPoolItemHolder(*this);
-    }
+    if (nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()))
+        getPool().registerPoolItemHolder(*this);
 
     return *this;
 }

Reply via email to