[Libreoffice-commits] core.git: svl/source

Stephan Bergmann sbergman at redhat.com
Wed Jan 6 07:22:11 PST 2016


 svl/source/items/itempool.cxx |   97 +++++++++++++++++++-----------------------
 1 file changed, 46 insertions(+), 51 deletions(-)

New commits:
commit 43de9a5b0f68a77a10595b3f69c6145cd9be05b6
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Jan 6 16:13:52 2016 +0100

    What these SAL_INFO probably want to tell us...
    
    ...given the oldest incarnation of the code still available is
    
      HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
      if ( ppStaticDefaults )
    
    and
    
      HACK( "fuer Image, dort gibt es derzeit keine Statics - Bug" )
      if ( ppStaticDefaults )
    
    from cf7e1f9cc99e7c260cfab823f2c47f56035bdbd0 "INTEGRATION:
    CWS visibility03: #i45006# Moved from svtools/source/items/ (for
    svl/items1.lib)"...
    
    ...is that ppStaticDefaults should really be non-null, but "Image" (Draw?
    Impress?) needed a temporary (?) hack there.
    
    Test that assumption by asserting that ppStaticDefaults is non-null.
    
    Change-Id: I2a75547618da1d211c44176e4593f6951a0e0298

diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx
index d8a19b9..f58dbad 100644
--- a/svl/source/items/itempool.cxx
+++ b/svl/source/items/itempool.cxx
@@ -29,6 +29,7 @@
 #include "poolio.hxx"
 
 #include <algorithm>
+#include <cassert>
 #include <vector>
 
 
@@ -401,35 +402,32 @@ void SfxItemPool::SetSecondaryPool( SfxItemPool *pPool )
     if ( pImp->mpSecondary )
     {
 #ifdef DBG_UTIL
-        SAL_INFO( "svl.items", "for Image: there are not statics; this is a bug" );
-        if ( pImp->ppStaticDefaults )
+        // Delete() did not yet run?
+        if ( !pImp->maPoolItems.empty() && !pImp->mpSecondary->pImp->maPoolItems.empty() )
         {
-            // Delete() did not yet run?
-            if ( !pImp->maPoolItems.empty() && !pImp->mpSecondary->pImp->maPoolItems.empty() )
-            {
                 // Does the Master have SetItems?
-                bool bHasSetItems = false;
-                for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i )
-                    bHasSetItems = dynamic_cast<const SfxSetItem *>(pImp->ppStaticDefaults[i]) != nullptr;
-
-                // Detached Pools must be empty
-                bool bOK = bHasSetItems;
-                for ( sal_uInt16 n = 0;
-                      bOK && n <= pImp->mpSecondary->pImp->mnEnd - pImp->mpSecondary->pImp->mnStart;
-                      ++n )
+            bool bHasSetItems = false;
+            assert(pImp->ppStaticDefaults);
+            for ( sal_uInt16 i = 0; !bHasSetItems && i < pImp->mnEnd - pImp->mnStart; ++i )
+                bHasSetItems = dynamic_cast<const SfxSetItem *>(pImp->ppStaticDefaults[i]) != nullptr;
+
+            // Detached Pools must be empty
+            bool bOK = bHasSetItems;
+            for ( sal_uInt16 n = 0;
+                  bOK && n <= pImp->mpSecondary->pImp->mnEnd - pImp->mpSecondary->pImp->mnStart;
+                  ++n )
+            {
+                SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n];
+                if ( pItemArr )
                 {
-                    SfxPoolItemArray_Impl* pItemArr = pImp->mpSecondary->pImp->maPoolItems[n];
-                    if ( pItemArr )
-                    {
-                        SfxPoolItemArrayBase_Impl::iterator ppHtArr =   pItemArr->begin();
-                        for( size_t i = pItemArr->size(); i; ++ppHtArr, --i )
-                            if ( !(*ppHtArr) )
-                            {
-                                OSL_FAIL( "old secondary pool must be empty" );
-                                bOK = false;
-                                break;
-                            }
-                    }
+                    SfxPoolItemArrayBase_Impl::iterator ppHtArr =   pItemArr->begin();
+                    for( size_t i = pItemArr->size(); i; ++ppHtArr, --i )
+                        if ( !(*ppHtArr) )
+                        {
+                            OSL_FAIL( "old secondary pool must be empty" );
+                            bOK = false;
+                            break;
+                        }
                 }
             }
         }
@@ -519,38 +517,35 @@ void SfxItemPool::Delete()
     sal_uInt16 nArrCnt;
 
     // Collect the SetItems first
-    SAL_INFO( "svl.items", "for Image: there are not statics there yet; this is a bug" );
-    if ( pImp->ppStaticDefaults )
+    assert(pImp->ppStaticDefaults);
+    for ( nArrCnt = GetSize_Impl();
+          nArrCnt;
+          --nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
     {
-        for ( nArrCnt = GetSize_Impl();
-                nArrCnt;
-                --nArrCnt, ++itrItemArr, ++ppDefaultItem, ++ppStaticDefaultItem )
+        // *ppStaticDefaultItem could've already been deleted in a class derived
+        // from SfxItemPool
+        // This causes chaos in Itempool!
+        if ( *ppStaticDefaultItem && dynamic_cast< const SfxSetItem* >(*ppStaticDefaultItem) !=  nullptr )
         {
-            // *ppStaticDefaultItem could've already been deleted in a class derived
-            // from SfxItemPool
-            // This causes chaos in Itempool!
-            if ( *ppStaticDefaultItem && dynamic_cast< const SfxSetItem* >(*ppStaticDefaultItem) !=  nullptr )
+            if ( *itrItemArr )
             {
-                if ( *itrItemArr )
-                {
-                    SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
-                    for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
-                        if (*ppHtArr)
-                        {
+                SfxPoolItemArrayBase_Impl::iterator ppHtArr = (*itrItemArr)->begin();
+                for ( size_t n = (*itrItemArr)->size(); n; --n, ++ppHtArr )
+                    if (*ppHtArr)
+                    {
 #ifdef DBG_UTIL
-                            ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
+                        ReleaseRef( **ppHtArr, (*ppHtArr)->GetRefCount() );
 #endif
-                            delete *ppHtArr;
-                        }
-                    DELETEZ( *itrItemArr );
-                }
-                if ( *ppDefaultItem )
-                {
+                        delete *ppHtArr;
+                    }
+                DELETEZ( *itrItemArr );
+            }
+            if ( *ppDefaultItem )
+            {
 #ifdef DBG_UTIL
-                    SetRefCount( **ppDefaultItem, 0 );
+                SetRefCount( **ppDefaultItem, 0 );
 #endif
-                    DELETEZ( *ppDefaultItem );
-                }
+                DELETEZ( *ppDefaultItem );
             }
         }
     }


More information about the Libreoffice-commits mailing list