Reverted "Leak TypeDescriptor_Init_Impl to avoid problems at exit."

(This reverts commit 0ba6bd3ddc025666a6d4bb0640bf443728b23bd3.)

The problems worked-around there are no longer observed by me, so they
were hopefully only a temporal problem (the real root cause had never
been found back then).  If problems start to pop up again, we'll need
to have another look at this.
This commit is contained in:
Stephan Bergmann
2012-04-26 09:26:42 +02:00
parent 5e80561c11
commit 61a8905c48

View File

@@ -368,26 +368,18 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() SAL_THROW(())
} }
}; };
namespace { namespace { struct Init : public rtl::Static< TypeDescriptor_Init_Impl, Init > {}; }
struct Init: public rtl::StaticWithInit< TypeDescriptor_Init_Impl *, Init > {
TypeDescriptor_Init_Impl * operator ()() const {
return new TypeDescriptor_Init_Impl; // leaked
}
};
}
extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_registerCallback( extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_registerCallback(
void * pContext, typelib_typedescription_Callback pCallback ) void * pContext, typelib_typedescription_Callback pCallback )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
// todo mt safe: guard is no solution, can not acquire while calling callback! // todo mt safe: guard is no solution, can not acquire while calling callback!
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
// OslGuard aGuard( rInit->getMutex() ); // OslGuard aGuard( rInit.getMutex() );
if( !rInit->pCallbacks ) if( !rInit.pCallbacks )
rInit->pCallbacks = new CallbackSet_Impl; rInit.pCallbacks = new CallbackSet_Impl;
rInit->pCallbacks->push_back( CallbackEntry( pContext, pCallback ) ); rInit.pCallbacks->push_back( CallbackEntry( pContext, pCallback ) );
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@@ -395,19 +387,19 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_revokeCallback(
void * pContext, typelib_typedescription_Callback pCallback ) void * pContext, typelib_typedescription_Callback pCallback )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( rInit->pCallbacks ) if( rInit.pCallbacks )
{ {
// todo mt safe: guard is no solution, can not acquire while calling callback! // todo mt safe: guard is no solution, can not acquire while calling callback!
// OslGuard aGuard( rInit->getMutex() ); // OslGuard aGuard( rInit.getMutex() );
CallbackEntry aEntry( pContext, pCallback ); CallbackEntry aEntry( pContext, pCallback );
CallbackSet_Impl::iterator iPos( rInit->pCallbacks->begin() ); CallbackSet_Impl::iterator iPos( rInit.pCallbacks->begin() );
while (!(iPos == rInit->pCallbacks->end())) while (!(iPos == rInit.pCallbacks->end()))
{ {
if (*iPos == aEntry) if (*iPos == aEntry)
{ {
rInit->pCallbacks->erase( iPos ); rInit.pCallbacks->erase( iPos );
iPos = rInit->pCallbacks->begin(); iPos = rInit.pCallbacks->begin();
} }
else else
{ {
@@ -453,7 +445,7 @@ static inline void typelib_typedescription_initTables(
} }
} }
MutexGuard aGuard( Init::get()->getMutex() ); MutexGuard aGuard( Init::get().getMutex() );
if( !pTD->bComplete ) if( !pTD->bComplete )
{ {
// create the index table from member to function table // create the index table from member to function table
@@ -526,8 +518,8 @@ bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
typelib_TypeDescription * pTD = 0; typelib_TypeDescription * pTD = 0;
// on demand access of complete td // on demand access of complete td
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
rInit->callChain( &pTD, (*ppTypeDescr)->pTypeName ); rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName );
if (pTD) if (pTD)
{ {
if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass) if (typelib_TypeClass_TYPEDEF == pTD->eTypeClass)
@@ -560,17 +552,17 @@ bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) {
OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one OSL_ASSERT( pTD == *ppTypeDescr ); // has to merge into existing one
// insert into the chache // insert into the chache
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
if( !rInit->pCache ) if( !rInit.pCache )
rInit->pCache = new TypeDescriptionList_Impl; rInit.pCache = new TypeDescriptionList_Impl;
if( (sal_Int32)rInit->pCache->size() >= nCacheSize ) if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
{ {
typelib_typedescription_release( rInit->pCache->front() ); typelib_typedescription_release( rInit.pCache->front() );
rInit->pCache->pop_front(); rInit.pCache->pop_front();
} }
// descriptions in the cache must be acquired! // descriptions in the cache must be acquired!
typelib_typedescription_acquire( pTD ); typelib_typedescription_acquire( pTD );
rInit->pCache->push_back( pTD ); rInit.pCache->push_back( pTD );
OSL_ASSERT( OSL_ASSERT(
pTD->bComplete pTD->bComplete
@@ -619,7 +611,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nArrayTypeDescriptionCount ); &Init::get().nArrayTypeDescriptionCount );
#endif #endif
pIndirect->pType = 0; pIndirect->pType = 0;
pTmp->nDimensions = 0; pTmp->nDimensions = 0;
@@ -634,7 +626,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nIndirectTypeDescriptionCount ); &Init::get().nIndirectTypeDescriptionCount );
#endif #endif
pTmp->pType = 0; pTmp->pType = 0;
} }
@@ -647,7 +639,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nUnionTypeDescriptionCount ); &Init::get().nUnionTypeDescriptionCount );
#endif #endif
pTmp->nMembers = 0; pTmp->nMembers = 0;
pTmp->pDiscriminantTypeRef = 0; pTmp->pDiscriminantTypeRef = 0;
@@ -666,7 +658,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nCompoundTypeDescriptionCount ); &Init::get().nCompoundTypeDescriptionCount );
#endif #endif
pTmp->aBase.pBaseTypeDescription = 0; pTmp->aBase.pBaseTypeDescription = 0;
pTmp->aBase.nMembers = 0; pTmp->aBase.nMembers = 0;
@@ -685,7 +677,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nCompoundTypeDescriptionCount ); &Init::get().nCompoundTypeDescriptionCount );
#endif #endif
pTmp->pBaseTypeDescription = 0; pTmp->pBaseTypeDescription = 0;
pTmp->nMembers = 0; pTmp->nMembers = 0;
@@ -701,7 +693,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nEnumTypeDescriptionCount ); &Init::get().nEnumTypeDescriptionCount );
#endif #endif
pTmp->nDefaultEnumValue = 0; pTmp->nDefaultEnumValue = 0;
pTmp->nEnumValues = 0; pTmp->nEnumValues = 0;
@@ -716,7 +708,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nInterfaceTypeDescriptionCount ); &Init::get().nInterfaceTypeDescriptionCount );
#endif #endif
pTmp->pBaseTypeDescription = 0; pTmp->pBaseTypeDescription = 0;
pTmp->nMembers = 0; pTmp->nMembers = 0;
@@ -757,7 +749,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
pRet = (typelib_TypeDescription *)pTmp; pRet = (typelib_TypeDescription *)pTmp;
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( osl_incrementInterlockedCount(
&Init::get()->nInterfaceAttributeTypeDescriptionCount ); &Init::get().nInterfaceAttributeTypeDescriptionCount );
#endif #endif
pTmp->aBase.pMemberName = 0; pTmp->aBase.pMemberName = 0;
pTmp->pAttributeTypeRef = 0; pTmp->pAttributeTypeRef = 0;
@@ -775,7 +767,7 @@ extern "C" void SAL_CALL typelib_typedescription_newEmpty(
{ {
pRet = new typelib_TypeDescription(); pRet = new typelib_TypeDescription();
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( &Init::get()->nTypeDescriptionCount ); osl_incrementInterlockedCount( &Init::get().nTypeDescriptionCount );
#endif #endif
} }
} }
@@ -1607,13 +1599,13 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_release(
OSL_ASSERT(ref >= 0); OSL_ASSERT(ref >= 0);
if (0 == ref) if (0 == ref)
{ {
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( reallyWeak( pTD->eTypeClass ) ) if( reallyWeak( pTD->eTypeClass ) )
{ {
if( pTD->pWeakRef ) if( pTD->pWeakRef )
{ {
{ {
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
// remove this description from the weak reference // remove this description from the weak reference
pTD->pWeakRef->pType = 0; pTD->pWeakRef->pType = 0;
} }
@@ -1623,14 +1615,14 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_release(
else else
{ {
// this description is a reference too, so remove it from the hash table // this description is a reference too, so remove it from the hash table
if( rInit->pWeakMap ) if( rInit.pWeakMap )
{ {
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit->pWeakMap->find( (sal_Unicode*)pTD->pTypeName->buffer ); WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pTD->pTypeName->buffer );
if( aIt != rInit->pWeakMap->end() && (void *)(*aIt).second == (void *)pTD ) if( aIt != rInit.pWeakMap->end() && (void *)(*aIt).second == (void *)pTD )
{ {
// remove only if it contains the same object // remove only if it contains the same object
rInit->pWeakMap->erase( aIt ); rInit.pWeakMap->erase( aIt );
} }
} }
} }
@@ -1642,32 +1634,32 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_release(
switch( pTD->eTypeClass ) switch( pTD->eTypeClass )
{ {
case typelib_TypeClass_ARRAY: case typelib_TypeClass_ARRAY:
osl_decrementInterlockedCount( &rInit->nArrayTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nArrayTypeDescriptionCount );
break; break;
case typelib_TypeClass_SEQUENCE: case typelib_TypeClass_SEQUENCE:
osl_decrementInterlockedCount( &rInit->nIndirectTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nIndirectTypeDescriptionCount );
break; break;
case typelib_TypeClass_UNION: case typelib_TypeClass_UNION:
osl_decrementInterlockedCount( &rInit->nUnionTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nUnionTypeDescriptionCount );
break; break;
case typelib_TypeClass_STRUCT: case typelib_TypeClass_STRUCT:
case typelib_TypeClass_EXCEPTION: case typelib_TypeClass_EXCEPTION:
osl_decrementInterlockedCount( &rInit->nCompoundTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nCompoundTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE: case typelib_TypeClass_INTERFACE:
osl_decrementInterlockedCount( &rInit->nInterfaceTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nInterfaceTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE_METHOD: case typelib_TypeClass_INTERFACE_METHOD:
osl_decrementInterlockedCount( &rInit->nInterfaceMethodTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nInterfaceMethodTypeDescriptionCount );
break; break;
case typelib_TypeClass_INTERFACE_ATTRIBUTE: case typelib_TypeClass_INTERFACE_ATTRIBUTE:
osl_decrementInterlockedCount( &rInit->nInterfaceAttributeTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nInterfaceAttributeTypeDescriptionCount );
break; break;
case typelib_TypeClass_ENUM: case typelib_TypeClass_ENUM:
osl_decrementInterlockedCount( &rInit->nEnumTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nEnumTypeDescriptionCount );
break; break;
default: default:
osl_decrementInterlockedCount( &rInit->nTypeDescriptionCount ); osl_decrementInterlockedCount( &rInit.nTypeDescriptionCount );
} }
#endif #endif
@@ -1681,8 +1673,8 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_register(
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
// connect the description with the weak reference // connect the description with the weak reference
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
ClearableMutexGuard aGuard( rInit->getMutex() ); ClearableMutexGuard aGuard( rInit.getMutex() );
typelib_TypeDescriptionReference * pTDR = 0; typelib_TypeDescriptionReference * pTDR = 0;
typelib_typedescriptionreference_getByName( &pTDR, (*ppNewDescription)->pTypeName ); typelib_typedescriptionreference_getByName( &pTDR, (*ppNewDescription)->pTypeName );
@@ -1785,11 +1777,11 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_register(
else else
{ {
pTDR = (typelib_TypeDescriptionReference *)*ppNewDescription; pTDR = (typelib_TypeDescriptionReference *)*ppNewDescription;
if( !rInit->pWeakMap ) if( !rInit.pWeakMap )
rInit->pWeakMap = new WeakMap_Impl; rInit.pWeakMap = new WeakMap_Impl;
// description is the weak itself, so register it // description is the weak itself, so register it
(*rInit->pWeakMap)[pTDR->pTypeName->buffer] = pTDR; (*rInit.pWeakMap)[pTDR->pTypeName->buffer] = pTDR;
OSL_ASSERT( (void *)*ppNewDescription == (void *)pTDR ); OSL_ASSERT( (void *)*ppNewDescription == (void *)pTDR );
} }
@@ -2107,12 +2099,12 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
} }
static sal_Bool bInited = sal_False; static sal_Bool bInited = sal_False;
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( !bInited ) if( !bInited )
{ {
// guard against multi thread access // guard against multi thread access
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
if( !bInited ) if( !bInited )
{ {
// avoid recursion during the next ...new calls // avoid recursion during the next ...new calls
@@ -2176,7 +2168,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
{ {
{ {
// guard against multi thread access // guard against multi thread access
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
// pTDR->pType->pWeakRef == 0 means that the description is empty // pTDR->pType->pWeakRef == 0 means that the description is empty
if( pTDR->pType && pTDR->pType->pWeakRef ) if( pTDR->pType && pTDR->pType->pWeakRef )
{ {
@@ -2249,7 +2241,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
if (0 == *ppRet) if (0 == *ppRet)
{ {
// on demand access // on demand access
rInit->callChain( ppRet, pName ); rInit.callChain( ppRet, pName );
} }
if( *ppRet ) if( *ppRet )
@@ -2272,17 +2264,17 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescription_getByName(
typelib_typedescription_register( ppRet ); typelib_typedescription_register( ppRet );
// insert into the chache // insert into the chache
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
if( !rInit->pCache ) if( !rInit.pCache )
rInit->pCache = new TypeDescriptionList_Impl; rInit.pCache = new TypeDescriptionList_Impl;
if( (sal_Int32)rInit->pCache->size() >= nCacheSize ) if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
{ {
typelib_typedescription_release( rInit->pCache->front() ); typelib_typedescription_release( rInit.pCache->front() );
rInit->pCache->pop_front(); rInit.pCache->pop_front();
} }
// descriptions in the cache must be acquired! // descriptions in the cache must be acquired!
typelib_typedescription_acquire( *ppRet ); typelib_typedescription_acquire( *ppRet );
rInit->pCache->push_back( *ppRet ); rInit.pCache->push_back( *ppRet );
} }
} }
} }
@@ -2303,12 +2295,12 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
typelib_TypeClass eTypeClass, rtl_uString * pTypeName ) typelib_TypeClass eTypeClass, rtl_uString * pTypeName )
SAL_THROW_EXTERN_C() SAL_THROW_EXTERN_C()
{ {
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( eTypeClass == typelib_TypeClass_TYPEDEF ) if( eTypeClass == typelib_TypeClass_TYPEDEF )
{ {
// on demand access // on demand access
typelib_TypeDescription * pRet = 0; typelib_TypeDescription * pRet = 0;
rInit->callChain( &pRet, pTypeName ); rInit.callChain( &pRet, pTypeName );
if( pRet ) if( pRet )
{ {
// typedescription found // typedescription found
@@ -2330,15 +2322,15 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
typelib_typedescription_register( &pRet ); typelib_typedescription_register( &pRet );
// insert into the chache // insert into the chache
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
if( !rInit->pCache ) if( !rInit.pCache )
rInit->pCache = new TypeDescriptionList_Impl; rInit.pCache = new TypeDescriptionList_Impl;
if( (sal_Int32)rInit->pCache->size() >= nCacheSize ) if( (sal_Int32)rInit.pCache->size() >= nCacheSize )
{ {
typelib_typedescription_release( rInit->pCache->front() ); typelib_typedescription_release( rInit.pCache->front() );
rInit->pCache->pop_front(); rInit.pCache->pop_front();
} }
rInit->pCache->push_back( pRet ); rInit.pCache->push_back( pRet );
// pRet kept acquired for cache // pRet kept acquired for cache
typelib_typedescriptionreference_acquire( pRet->pWeakRef ); typelib_typedescriptionreference_acquire( pRet->pWeakRef );
@@ -2359,7 +2351,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
return; return;
} }
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
typelib_typedescriptionreference_getByName( ppTDR, pTypeName ); typelib_typedescriptionreference_getByName( ppTDR, pTypeName );
if( *ppTDR ) if( *ppTDR )
return; return;
@@ -2368,7 +2360,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
{ {
typelib_TypeDescriptionReference * pTDR = new typelib_TypeDescriptionReference(); typelib_TypeDescriptionReference * pTDR = new typelib_TypeDescriptionReference();
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_incrementInterlockedCount( &rInit->nTypeDescriptionReferenceCount ); osl_incrementInterlockedCount( &rInit.nTypeDescriptionReferenceCount );
#endif #endif
pTDR->nRefCount = 1; pTDR->nRefCount = 1;
pTDR->nStaticRefCount = 0; pTDR->nStaticRefCount = 0;
@@ -2387,11 +2379,11 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_new(
(*(typelib_TypeDescription ** )ppTDR)->bComplete = sal_False; (*(typelib_TypeDescription ** )ppTDR)->bComplete = sal_False;
} }
if( !rInit->pWeakMap ) if( !rInit.pWeakMap )
rInit->pWeakMap = new WeakMap_Impl; rInit.pWeakMap = new WeakMap_Impl;
// Heavy hack, the const sal_Unicode * is hold by the typedescription reference // Heavy hack, the const sal_Unicode * is hold by the typedescription reference
// not registered // not registered
rInit->pWeakMap->operator[]( (*ppTDR)->pTypeName->buffer ) = *ppTDR; rInit.pWeakMap->operator[]( (*ppTDR)->pTypeName->buffer ) = *ppTDR;
} }
//------------------------------------------------------------------------ //------------------------------------------------------------------------
@@ -2412,22 +2404,22 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_release
{ {
if( ! ::osl_decrementInterlockedCount( &pRef->nRefCount ) ) if( ! ::osl_decrementInterlockedCount( &pRef->nRefCount ) )
{ {
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( rInit->pWeakMap ) if( rInit.pWeakMap )
{ {
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::iterator aIt = rInit->pWeakMap->find( (sal_Unicode*)pRef->pTypeName->buffer ); WeakMap_Impl::iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pRef->pTypeName->buffer );
if( !(aIt == rInit->pWeakMap->end()) && (*aIt).second == pRef ) if( !(aIt == rInit.pWeakMap->end()) && (*aIt).second == pRef )
{ {
// remove only if it contains the same object // remove only if it contains the same object
rInit->pWeakMap->erase( aIt ); rInit.pWeakMap->erase( aIt );
} }
} }
rtl_uString_release( pRef->pTypeName ); rtl_uString_release( pRef->pTypeName );
OSL_ASSERT( pRef->pType == 0 ); OSL_ASSERT( pRef->pType == 0 );
#if OSL_DEBUG_LEVEL > 1 #if OSL_DEBUG_LEVEL > 1
osl_decrementInterlockedCount( &rInit->nTypeDescriptionReferenceCount ); osl_decrementInterlockedCount( &rInit.nTypeDescriptionReferenceCount );
#endif #endif
delete pRef; delete pRef;
} }
@@ -2458,7 +2450,7 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_typedescriptionreference_getDesc
} }
{ {
MutexGuard aGuard( Init::get()->getMutex() ); MutexGuard aGuard( Init::get().getMutex() );
// pRef->pType->pWeakRef == 0 means that the description is empty // pRef->pType->pWeakRef == 0 means that the description is empty
if( pRef->pType && pRef->pType->pWeakRef ) if( pRef->pType && pRef->pType->pWeakRef )
{ {
@@ -2497,12 +2489,12 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_getByName(
typelib_typedescriptionreference_release( *ppRet ); typelib_typedescriptionreference_release( *ppRet );
*ppRet = 0; *ppRet = 0;
} }
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
if( rInit->pWeakMap ) if( rInit.pWeakMap )
{ {
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
WeakMap_Impl::const_iterator aIt = rInit->pWeakMap->find( (sal_Unicode*)pName->buffer ); WeakMap_Impl::const_iterator aIt = rInit.pWeakMap->find( (sal_Unicode*)pName->buffer );
if( !(aIt == rInit->pWeakMap->end()) ) // != failed on msc4.2 if( !(aIt == rInit.pWeakMap->end()) ) // != failed on msc4.2
{ {
sal_Int32 n = ::osl_incrementInterlockedCount( &(*aIt).second->nRefCount ); sal_Int32 n = ::osl_incrementInterlockedCount( &(*aIt).second->nRefCount );
if( n > 1 ) if( n > 1 )
@@ -2554,14 +2546,14 @@ extern "C" CPPU_DLLPUBLIC void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize
OSL_ENSURE( nNewSize >= 0, "### illegal cache size given!" ); OSL_ENSURE( nNewSize >= 0, "### illegal cache size given!" );
if (nNewSize >= 0) if (nNewSize >= 0)
{ {
TypeDescriptor_Init_Impl *rInit = Init::get(); TypeDescriptor_Init_Impl &rInit = Init::get();
MutexGuard aGuard( rInit->getMutex() ); MutexGuard aGuard( rInit.getMutex() );
if ((nNewSize < nCacheSize) && rInit->pCache) if ((nNewSize < nCacheSize) && rInit.pCache)
{ {
while ((sal_Int32)rInit->pCache->size() != nNewSize) while ((sal_Int32)rInit.pCache->size() != nNewSize)
{ {
typelib_typedescription_release( rInit->pCache->front() ); typelib_typedescription_release( rInit.pCache->front() );
rInit->pCache->pop_front(); rInit.pCache->pop_front();
} }
} }
nCacheSize = nNewSize; nCacheSize = nNewSize;