Hi. I have created patch, which replace SV_DECL_PTRARR with std::vector. It is first step to resolve old bug: http://www.openoffice.org/issues/show_bug.cgi?id=84159
Unfortunately this patch is not works correctly. After compile/run OpenOffice the application freeze. I do something wrog, but I cannot find bug which couse this freeze. Here is patch prepared by me: diff -r fad23fb34ff7 svl/source/inc/poolio.hxx --- a/svl/source/inc/poolio.hxx Thu Jun 17 14:29:52 2010 +0200 +++ b/svl/source/inc/poolio.hxx Mon Jun 21 21:09:43 2010 +0200 @@ -53,8 +53,9 @@ {} }; -SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 ) SV_DECL_PTRARR_DEL( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl*, 0, 2 ) +//SV_DECL_PTRARR( SfxPoolItemArrayBase_Impl, SfxPoolItem*, 0, 5 ) +typedef std::vector<SfxPoolItem*> SfxPoolItemArrayBase_Impl; struct SfxPoolItemArray_Impl: public SfxPoolItemArrayBase_Impl { diff -r fad23fb34ff7 svl/source/items/itempool.cxx --- a/svl/source/items/itempool.cxx Thu Jun 17 14:29:52 2010 +0200 +++ b/svl/source/items/itempool.cxx Mon Jun 21 21:09:43 2010 +0200 @@ -39,13 +39,7 @@ #include <svl/smplhint.hxx> #include "poolio.hxx" #include <algorithm> - -// STATIC DATA ----------------------------------------------------------- - - -//======================================================================== - +#include <vector> SV_IMPL_PTRARR( SfxPoolVersionArr_Impl, SfxPoolVersion_Impl* ); //======================================================================== @@ -275,13 +269,12 @@ (*( ppPoolDefaults + n ))->SetKind( SFX_ITEMS_POOLDEFAULT ); } - // Version-Map kopieren - USHORT nVerCount = rPool.pImp->aVersions.Count(); - for ( USHORT nVer = 0; nVer < nVerCount; ++nVer ) + // Copy Version-Map + for ( size_t nVer = 0; nVer <rPool.pImp->aVersions.size(); ++nVer ) { - const SfxPoolVersion_Impl *pOld = rPool.pImp->aVersions.GetObject(nVer); - const SfxPoolVersion_Impl *pNew = new SfxPoolVersion_Impl( *pOld ); - pImp->aVersions.Insert( pNew, nVer ); + const SfxPoolVersion_Impl* pOld = rPool.pImp->aVersions[nVer]; + SfxPoolVersion_Impl* pNew = new SfxPoolVersion_Impl( *pOld ); + pImp->aVersions.push_back( pNew ); } // Verkettung wiederherstellen @@ -455,8 +448,8 @@ if ( *ppItemArr ) { SfxPoolItem** ppHtArr = - (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT i = (*ppItemArr)->Count(); i; ++ppHtArr, --i ) + (SfxPoolItem**)(*ppItemArr); + for( size_t i = (*ppItemArr)->size(); i; ++ppHtArr, --i ) if ( !(*ppHtArr) ) { DBG_ERROR( "old secondary pool must be empty" ); @@ -582,8 +575,8 @@ { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -614,8 +607,8 @@ { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -663,8 +656,8 @@ ((*ppDefaultItem && (*ppDefaultItem)->ISA(SfxSetItem)) || (*ppStaticDefaultItem)->ISA(SfxSetItem)) ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) { DELETEZ(*ppHtArr); @@ -681,8 +674,8 @@ { if ( *ppItemArr ) { - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for ( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for ( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if ( *ppHtArr && !(*ppHtArr)->GetRefCount() ) DELETEZ( *ppHtArr ); } @@ -783,14 +776,14 @@ *ppItemArr = new SfxPoolItemArray_Impl; SfxPoolItem **ppFree = 0; - SfxPoolItem** ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData(); + SfxPoolItem** ppHtArray = (SfxPoolItem**)(*ppItemArr); if ( IsItemFlag_Impl( nIndex, SFX_ITEM_POOLABLE ) ) { // wenn es ueberhaupt gepoolt ist, koennte es schon drin sein if ( IsPooledItem(&rItem) ) { // 1. Schleife: teste ob der Pointer vorhanden ist. - for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArray, --n ) + for( size_t n = (*ppItemArr)->size(); n; ++ppHtArray, --n ) if( &rItem == (*ppHtArray) ) { AddRef( **ppHtArray ); @@ -799,8 +792,8 @@ } // 2. Schleife: dann muessen eben die Attribute verglichen werden - USHORT n; - for ( n = (*ppItemArr)->Count(), ppHtArray = (SfxPoolItem**)(*ppItemArr)->GetData(); + size_t n; + for ( n = (*ppItemArr)->size(), ppHtArray = (SfxPoolItem**)(*ppItemArr); n; ++ppHtArray, --n ) { if ( *ppHtArray ) @@ -820,9 +813,9 @@ { // freien Platz suchen SfxPoolItem** ppHtArr; - USHORT n, nCount = (*ppItemArr)->Count(); + size_t n, nCount = (*ppItemArr)->size(); for ( n = (*ppItemArr)->nFirstFree, - ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData() + n; + ppHtArr = (SfxPoolItem**)(*ppItemArr) + n; n < nCount; ++ppHtArr, ++n ) if ( !*ppHtArr ) @@ -853,9 +846,9 @@ #endif #endif AddRef( *pNewItem, pImp->nInitRefCount ); - const SfxPoolItem* pTemp = pNewItem; + SfxPoolItem* pTemp = pNewItem; if ( !ppFree ) - (*ppItemArr)->Insert( pTemp, (*ppItemArr)->Count() ); + (*ppItemArr)->push_back( pTemp ); else { DBG_ASSERT( *ppFree == 0, "using surrogate in use" ); @@ -915,8 +908,8 @@ // Item im eigenen Pool suchen SfxPoolItemArray_Impl** ppItemArr = (pImp->ppPoolItems + nIndex); SFX_ASSERT( *ppItemArr, rItem.Which(), "removing Item not in Pool" ); - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; ++ppHtArr, --n ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for( size_t n = (*ppItemArr)->size(); n; ++ppHtArr, --n ) if( *ppHtArr == &rItem ) { if ( (*ppHtArr)->GetRefCount() ) //! @@ -928,7 +921,7 @@ } // ggf. kleinstmoegliche freie Position merken - USHORT nPos = (*ppItemArr)->Count() - n; + ULONG nPos = (*ppItemArr)->size() - n; if ( (*ppItemArr)->nFirstFree > nPos ) (*ppItemArr)->nFirstFree = nPos; @@ -1026,7 +1019,7 @@ return *(ppStaticDefaults + GetIndex_Impl(nWhich)); SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); - if( pItemArr && nOfst < pItemArr->Count() ) + if( pItemArr && nOfst < pItemArr->size() ) return (*pItemArr)[nOfst]; return 0; @@ -1048,7 +1041,7 @@ SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(nWhich)); if ( pItemArr ) - return pItemArr->Count(); + return pItemArr->size(); return 0; } diff -r fad23fb34ff7 svl/source/items/poolio.cxx --- a/svl/source/items/poolio.cxx Thu Jun 17 14:29:52 2010 +0200 +++ b/svl/source/items/poolio.cxx Mon Jun 21 21:09:43 2010 +0200 @@ -178,7 +178,7 @@ // Version-Maps { SfxMultiVarRecordWriter aVerRec( &rStream, SFX_ITEMPOOL_REC_VERSIONMAP, 0 ); - for ( USHORT nVerNo = 0; nVerNo < pImp->aVersions.Count(); ++nVerNo ) + for ( size_t nVerNo = 0; nVerNo < pImp->aVersions.size(); ++nVerNo ) { aVerRec.NewContent(); SfxPoolVersion_Impl *pVer = pImp->aVersions[nVerNo]; @@ -207,7 +207,7 @@ SfxPoolItemArray_Impl **pArr = pImp->ppPoolItems; SfxPoolItem **ppDefItem = ppStaticDefaults; const USHORT nSize = GetSize_Impl(); - for ( USHORT i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem ) + for ( size_t i = 0; i < nSize && !rStream.GetError(); ++i, ++pArr, ++ppDefItem ) { // Version des Items feststellen USHORT nItemVersion = (*ppDefItem)->GetVersion( _nFileFormatVersion ); @@ -229,16 +229,16 @@ aWhichIdsRec.NewContent(nSlotId, 0); rStream << (*ppDefItem)->Which(); rStream << nItemVersion; - const USHORT nCount = (*pArr)->Count(); + const USHORT nCount = (*pArr)->size(); DBG_ASSERT(nCount, "ItemArr ist leer"); rStream << nCount; // Items an sich schreiben SfxMultiMixRecordWriter aItemsRec( &rStream, SFX_ITEMPOOL_REC_ITEMS, 0 ); - for ( USHORT j = 0; j < nCount; ++j ) + for ( size_t j = 0; j < nCount; ++j ) { // Item selbst besorgen - const SfxPoolItem *pItem = (*pArr)->GetObject(j); + const SfxPoolItem *pItem = (*pArr)->at(j); if ( pItem && pItem->GetRefCount() ) //! siehe anderes MI-REF { aItemsRec.NewContent(j, 'X' ); @@ -353,8 +353,8 @@ if ( *ppItemArr ) { // "uber alle Items mit dieser Which-Id iterieren - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -390,7 +390,7 @@ SfxPoolItemArray_Impl *pNewArr = new SfxPoolItemArray_Impl( nItemCount ); SfxPoolItem *pItem = 0; - USHORT n, nLastSurrogate = USHORT(-1); + ULONG n, nLastSurrogate = ULONG(-1); while (aItemsRec.GetContent()) { // n"achstes Surrogat holen @@ -400,7 +400,7 @@ // fehlende auff"ullen for ( pItem = 0, n = nLastSurrogate+1; n < nSurrogate; ++n ) - pNewArr->C40_INSERT(SfxPoolItem, pItem, n); + pNewArr->push_back( pItem ); nLastSurrogate = nSurrogate; // Ref-Count und Item laden @@ -408,7 +408,7 @@ rStream >> nRef; pItem = pDefItem->Create(rStream, nVersion); - pNewArr->C40_INSERT(SfxPoolItem, pItem, nSurrogate); + pNewArr->push_back( pItem ); if ( !bPersistentRefCounts ) // bis <SfxItemPool::LoadCompleted()> festhalten @@ -424,7 +424,7 @@ // fehlende auff"ullen for ( pItem = 0, n = nLastSurrogate+1; n < nItemCount; ++n ) - pNewArr->C40_INSERT(SfxPoolItem, pItem, n); + pNewArr->push_back( pItem ); SfxPoolItemArray_Impl *pOldArr = *ppArr; *ppArr = pNewArr; @@ -432,25 +432,25 @@ // die Items merken, die schon im Pool sind int bEmpty = TRUE; if ( 0 != pOldArr ) - for ( n = 0; bEmpty && n < pOldArr->Count(); ++n ) - bEmpty = pOldArr->GetObject(n) == 0; + for ( n = 0; bEmpty && n < pOldArr->size(); ++n ) + bEmpty = pOldArr->at(n) == 0; DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" ); if ( !bEmpty ) { // f"ur alle alten suchen, ob ein gleiches neues existiert - for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld ) + for ( size_t nOld = 0; nOld < pOldArr->size(); ++nOld ) { SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { USHORT nFree = USHRT_MAX; - int bFound = FALSE; - USHORT nCount = (*ppArr)->Count(); + bool bFound = false; + ULONG nCount = (*ppArr)->size(); for ( USHORT nNew = nCount; !bFound && nNew--; ) { // geladenes Item SfxPoolItem *&rpNewItem = - (SfxPoolItem*&)(*ppArr)->GetData()[nNew]; + (SfxPoolItem*&)(*ppArr)->at(nNew); // surrogat unbenutzt? if ( !rpNewItem ) @@ -464,7 +464,7 @@ SetRefCount( *rpNewItem, 0 ); delete rpNewItem; rpNewItem = pOldItem; - bFound = TRUE; + bFound = true; } } @@ -472,9 +472,9 @@ if ( !bFound ) { if ( nFree != USHRT_MAX ) - (SfxPoolItem*&)(*ppArr)->GetData()[nFree] = pOldItem; + (SfxPoolItem*&)(*ppArr)->at(nFree) = pOldItem; else - (*ppArr)->C40_INSERT( SfxPoolItem, pOldItem, nCount ); + (*ppArr)->push_back( pOldItem ); } } } @@ -495,14 +495,14 @@ // "uber alle Which-Werte iterieren SfxPoolItemArray_Impl** ppItemArr = pImp->ppPoolItems; - for( USHORT nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr ) + for( size_t nArrCnt = GetSize_Impl(); nArrCnt; --nArrCnt, ++ppItemArr ) { // ist "uberhaupt ein Item mit dem Which-Wert da? if ( *ppItemArr ) { // "uber alle Items mit dieser Which-Id iterieren - SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr)->GetData(); - for( USHORT n = (*ppItemArr)->Count(); n; --n, ++ppHtArr ) + SfxPoolItem** ppHtArr = (SfxPoolItem**)(*ppItemArr); + for( size_t n = (*ppItemArr)->size(); n; --n, ++ppHtArr ) if (*ppHtArr) { #ifdef DBG_UTIL @@ -611,8 +611,8 @@ rStream >> nVersion >> nHStart >> nHEnd; USHORT nCount = nHEnd - nHStart + 1; - // Version neuer als bekannt? - if ( nVerNo >= pImp->aVersions.Count() ) + // Is new version is known? + if ( nVerNo >= pImp->aVersions.size() ) { // neue Version hinzufuegen USHORT *pMap = new USHORT[nCount]; @@ -799,8 +799,8 @@ USHORT nCount = nHEnd - nHStart + 1; USHORT nBytes = (nCount)*sizeof(USHORT); - // Version neuer als bekannt? - if ( nVerNo >= pImp->aVersions.Count() ) + // Is new version is known? + if ( nVerNo >= pImp->aVersions.size() ) { // neue Version hinzufuegen USHORT *pMap = new USHORT[nCount]; @@ -898,7 +898,8 @@ } } - pNewArr->C40_INSERT( SfxPoolItem, pItem, j); + //pNewArr->insert( pItem, j ); + pNewArr->push_back( pItem ); // restliche gespeicherte Laenge skippen (neueres Format) nLastPos = rStream.Tell(); @@ -924,24 +925,24 @@ // die Items merken, die schon im Pool sind int bEmpty = TRUE; if ( 0 != pOldArr ) - for ( USHORT n = 0; bEmpty && n < pOldArr->Count(); ++n ) - bEmpty = pOldArr->GetObject(n) == 0; + for ( size_t n = 0; bEmpty && n < pOldArr->size(); ++n ) + bEmpty = pOldArr->at(n) == 0; DBG_ASSERTWARNING( bEmpty, "loading non-empty pool" ); if ( !bEmpty ) { // f"ur alle alten suchen, ob ein gleiches neues existiert - for ( USHORT nOld = 0; nOld < pOldArr->Count(); ++nOld ) + for ( size_t nOld = 0; nOld < pOldArr->size(); ++nOld ) { SfxPoolItem *pOldItem = (*pOldArr)[nOld]; if ( pOldItem ) { - int bFound = FALSE; - for ( USHORT nNew = 0; - !bFound && nNew < (*ppArr)->Count(); + bool bFound = false; + for ( size_t nNew = 0; + !bFound && nNew < (*ppArr)->size(); ++nNew ) { SfxPoolItem *&rpNewItem = - (SfxPoolItem*&)(*ppArr)->GetData()[nNew]; + (SfxPoolItem*&)(*ppArr)->at(nNew); if ( rpNewItem && *rpNewItem == *pOldItem ) { @@ -949,7 +950,7 @@ SetRefCount( *rpNewItem, 0 ); delete rpNewItem; rpNewItem = pOldItem; - bFound = TRUE; + bFound = true; SFX_TRACE( "reusing item", pOldItem ); } } @@ -1120,7 +1121,7 @@ SfxPoolItemArray_Impl* pItemArr = *(pTarget->pImp->ppPoolItems + pTarget->GetIndex_Impl(rWhich)); - pItem = pItemArr && nSurrogat < pItemArr->Count() + pItem = pItemArr && nSurrogat < pItemArr->size() ? (*pItemArr)[nSurrogat] : 0; if ( !pItem ) @@ -1214,8 +1215,8 @@ SfxPoolItemArray_Impl* pItemArr = *(pImp->ppPoolItems + GetIndex_Impl(pItem->Which())); DBG_ASSERT(pItemArr, "ItemArr nicht vorhanden"); - const USHORT nCount = pItemArr->Count(); - for ( USHORT i = 0; i < nCount; ++i ) + const ULONG nCount = pItemArr->size(); + for ( size_t i = 0; i < nCount; ++i ) { const SfxPoolItem *p = (*pItemArr)[i]; if ( p == pItem ) @@ -1327,9 +1328,9 @@ { // neuen Map-Eintrag erzeugen und einf"ugen - const SfxPoolVersion_Impl *pVerMap = new SfxPoolVersion_Impl( + SfxPoolVersion_Impl *pVerMap = new SfxPoolVersion_Impl( nVer, nOldStart, nOldEnd, pOldWhichIdTab ); - pImp->aVersions.Insert( pVerMap, pImp->aVersions.Count() ); + pImp->aVersions.push_back( pVerMap ); DBG_ASSERT( nVer > pImp->nVersion, "Versions not sorted" ); pImp->nVersion = nVer; @@ -1398,7 +1399,7 @@ if ( nDiff > 0 ) { // von der Top-Version bis runter zur File-Version stufenweise mappen - for ( USHORT nMap = pImp->aVersions.Count(); nMap > 0; --nMap ) + for ( size_t nMap = pImp->aVersions.size(); nMap > 0; --nMap ) { SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap-1]; if ( pVerInfo->_nVer > pImp->nVersion ) @@ -1424,7 +1425,7 @@ else if ( nDiff < 0 ) { // von der File-Version bis zur aktuellen Version stufenweise mappen - for ( USHORT nMap = 0; nMap < pImp->aVersions.Count(); ++nMap ) + for ( size_t nMap = 0; nMap < pImp->aVersions.size(); ++nMap ) { SfxPoolVersion_Impl *pVerInfo = pImp->aVersions[nMap]; if ( pVerInfo->_nVer > pImp->nLoadingVersion ) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@openoffice.org For additional commands, e-mail: dev-h...@openoffice.org