diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-08 21:01:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-09 08:28:56 +0100 |
commit | b3c6b3a274b4c89d3572010794897c65b26571aa (patch) | |
tree | 87493b0306663ac6c818a71df9f83831914e296b | |
parent | RTF import: handle \snext (diff) | |
download | core-b3c6b3a274b4c89d3572010794897c65b26571aa.tar.gz core-b3c6b3a274b4c89d3572010794897c65b26571aa.zip |
rtl::Static to thread-safe static
Change-Id: I35e2a252708228bdbeaee557ef35763c64608653
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124884
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | basic/source/classes/codecompletecache.cxx | 31 | ||||
-rw-r--r-- | basic/source/classes/sbunoobj.cxx | 1 | ||||
-rw-r--r-- | basic/source/runtime/runtime.cxx | 1 | ||||
-rw-r--r-- | chart2/source/controller/main/ConfigurationAccess.cxx | 11 | ||||
-rw-r--r-- | chart2/source/model/main/Diagram.cxx | 86 | ||||
-rw-r--r-- | chart2/source/view/charttypes/ConfigAccess.cxx | 13 | ||||
-rw-r--r-- | comphelper/source/misc/namedvaluecollection.cxx | 1 | ||||
-rw-r--r-- | cppu/source/typelib/static_types.cxx | 27 | ||||
-rw-r--r-- | cppu/source/typelib/typelib.cxx | 49 | ||||
-rw-r--r-- | cppu/source/uno/lbenv.cxx | 13 |
10 files changed, 103 insertions, 130 deletions
diff --git a/basic/source/classes/codecompletecache.cxx b/basic/source/classes/codecompletecache.cxx index e2993c28581a..8f03797c32dd 100644 --- a/basic/source/classes/codecompletecache.cxx +++ b/basic/source/classes/codecompletecache.cxx @@ -19,13 +19,16 @@ #include <basic/codecompletecache.hxx> #include <iostream> -#include <rtl/instance.hxx> #include <officecfg/Office/BasicIDE.hxx> #include <officecfg/Office/Common.hxx> namespace { - class theCodeCompleteOptions: public ::rtl::Static< CodeCompleteOptions, theCodeCompleteOptions >{}; +CodeCompleteOptions& theCodeCompleteOptions() +{ + static CodeCompleteOptions SINGLETON; + return SINGLETON; +} } CodeCompleteOptions::CodeCompleteOptions() @@ -40,62 +43,62 @@ CodeCompleteOptions::CodeCompleteOptions() bool CodeCompleteOptions::IsCodeCompleteOn() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bIsCodeCompleteOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bIsCodeCompleteOn; } void CodeCompleteOptions::SetCodeCompleteOn( bool b ) { - theCodeCompleteOptions::get().bIsCodeCompleteOn = b; + theCodeCompleteOptions().bIsCodeCompleteOn = b; } bool CodeCompleteOptions::IsExtendedTypeDeclaration() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bExtendedTypeDeclarationOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bExtendedTypeDeclarationOn; } void CodeCompleteOptions::SetExtendedTypeDeclaration( bool b ) { - theCodeCompleteOptions::get().bExtendedTypeDeclarationOn = b; + theCodeCompleteOptions().bExtendedTypeDeclarationOn = b; } bool CodeCompleteOptions::IsProcedureAutoCompleteOn() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bIsProcedureAutoCompleteOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bIsProcedureAutoCompleteOn; } void CodeCompleteOptions::SetProcedureAutoCompleteOn( bool b ) { - theCodeCompleteOptions::get().bIsProcedureAutoCompleteOn = b; + theCodeCompleteOptions().bIsProcedureAutoCompleteOn = b; } bool CodeCompleteOptions::IsAutoCloseQuotesOn() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bIsAutoCloseQuotesOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bIsAutoCloseQuotesOn; } void CodeCompleteOptions::SetAutoCloseQuotesOn( bool b ) { - theCodeCompleteOptions::get().bIsAutoCloseQuotesOn = b; + theCodeCompleteOptions().bIsAutoCloseQuotesOn = b; } bool CodeCompleteOptions::IsAutoCloseParenthesisOn() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bIsAutoCloseParenthesisOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bIsAutoCloseParenthesisOn; } void CodeCompleteOptions::SetAutoCloseParenthesisOn( bool b ) { - theCodeCompleteOptions::get().bIsAutoCloseParenthesisOn = b; + theCodeCompleteOptions().bIsAutoCloseParenthesisOn = b; } bool CodeCompleteOptions::IsAutoCorrectOn() { - return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions::get().bIsAutoCorrectOn; + return officecfg::Office::Common::Misc::ExperimentalMode::get() && theCodeCompleteOptions().bIsAutoCorrectOn; } void CodeCompleteOptions::SetAutoCorrectOn( bool b ) { - theCodeCompleteOptions::get().bIsAutoCorrectOn = b; + theCodeCompleteOptions().bIsAutoCorrectOn = b; } std::ostream& operator<< (std::ostream& aStream, const CodeCompleteDataCache& aCache) diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx index f9d378ea8865..9e1d31fb4ac1 100644 --- a/basic/source/classes/sbunoobj.cxx +++ b/basic/source/classes/sbunoobj.cxx @@ -32,7 +32,6 @@ #include <comphelper/processfactory.hxx> #include <cppuhelper/weakref.hxx> -#include <rtl/instance.hxx> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx index 11699093e022..00c90e30379d 100644 --- a/basic/source/runtime/runtime.cxx +++ b/basic/source/runtime/runtime.cxx @@ -41,7 +41,6 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> -#include <rtl/instance.hxx> #include <rtl/math.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/character.hxx> diff --git a/chart2/source/controller/main/ConfigurationAccess.cxx b/chart2/source/controller/main/ConfigurationAccess.cxx index 54a94adfa083..f6dfecc60113 100644 --- a/chart2/source/controller/main/ConfigurationAccess.cxx +++ b/chart2/source/controller/main/ConfigurationAccess.cxx @@ -22,7 +22,6 @@ #include <unotools/syslocale.hxx> #include <unotools/configitem.hxx> #include <unotools/localedatawrapper.hxx> -#include <rtl/instance.hxx> namespace chart { @@ -78,17 +77,13 @@ FieldUnit CalcConfigItem::getFieldUnit() return eResult; } -namespace -{ - //a CalcConfigItem Singleton - struct theCalcConfigItem : public rtl::Static< CalcConfigItem, theCalcConfigItem > {}; -} - namespace ConfigurationAccess { FieldUnit getFieldUnit() { - FieldUnit aUnit( theCalcConfigItem::get().getFieldUnit() ); + //a CalcConfigItem Singleton + static CalcConfigItem SINGLETON; + FieldUnit aUnit( SINGLETON.getFieldUnit() ); return aUnit; } } //namespace ConfigurationAccess diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx index f5d8afc5b172..8255115bead1 100644 --- a/chart2/source/model/main/Diagram.cxx +++ b/chart2/source/model/main/Diagram.cxx @@ -30,7 +30,6 @@ #include <unonames.hxx> #include <basegfx/numeric/ftools.hxx> -#include <rtl/instance.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> @@ -179,46 +178,31 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEVOID ); } -struct StaticDiagramDefaults_Initializer +const ::chart::tPropertyValueMap& StaticDiagramDefaults() { - ::chart::tPropertyValueMap* operator()() + static ::chart::tPropertyValueMap aStaticDefaults = []() { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEHBORDER, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEVBORDER, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEOUTLINE, false ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 ); - ::chart::SceneProperties::AddDefaultsToMap( rOutMap ); - } + ::chart::tPropertyValueMap aMap; + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_CONNECT_BARS, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEHBORDER, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEVBORDER, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEOUTLINE, false ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 ); + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 ); + ::chart::SceneProperties::AddDefaultsToMap( aMap ); + return aMap; + }(); + return aStaticDefaults; }; -struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer > +::cppu::OPropertyArrayHelper& StaticDiagramInfoHelper() { -}; - -struct StaticDiagramInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() + static ::cppu::OPropertyArrayHelper aPropHelper = []() { std::vector< css::beans::Property > aProperties; lcl_AddPropertiesToVector( aProperties ); @@ -228,26 +212,16 @@ private: std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer > -{ -}; - -struct StaticDiagramInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) ); - return &xPropertySetInfo; - } + return ::cppu::OPropertyArrayHelper( aProperties.data(), aProperties.size() ); + }(); + return aPropHelper; }; -struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer > +const uno::Reference< beans::XPropertySetInfo >& StaticDiagramInfo() { + static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDiagramInfoHelper() ) ); + return xPropertySetInfo; }; /// clones a UNO-sequence of UNO-References @@ -595,7 +569,7 @@ void Diagram::fireModifyEvent() // ____ OPropertySet ____ uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const { - const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get(); + const tPropertyValueMap& rStaticDefaults = StaticDiagramDefaults(); tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); if( aFound == rStaticDefaults.end() ) return uno::Any(); @@ -605,13 +579,13 @@ uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper() { - return *StaticDiagramInfoHelper::get(); + return StaticDiagramInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo() { - return *StaticDiagramInfo::get(); + return StaticDiagramInfo(); } // ____ XFastPropertySet ____ diff --git a/chart2/source/view/charttypes/ConfigAccess.cxx b/chart2/source/view/charttypes/ConfigAccess.cxx index e83385fb63d1..ce02c4817e0a 100644 --- a/chart2/source/view/charttypes/ConfigAccess.cxx +++ b/chart2/source/view/charttypes/ConfigAccess.cxx @@ -21,7 +21,6 @@ #include <unotools/configitem.hxx> #include <o3tl/any.hxx> -#include <rtl/instance.hxx> #include <com/sun/star/uno/Sequence.hxx> namespace chart @@ -59,19 +58,13 @@ bool ChartConfigItem::getUseErrorRectangle() return b && *b; } -namespace -{ -//a ChartConfigItem Singleton -struct theChartConfigItem : public rtl::Static<ChartConfigItem, theChartConfigItem> -{ -}; -} - namespace ConfigAccess { bool getUseErrorRectangle() { - bool bResult(theChartConfigItem::get().getUseErrorRectangle()); + //a ChartConfigItem Singleton + static ChartConfigItem SINGLETON; + bool bResult(SINGLETON.getUseErrorRectangle()); return bResult; } } //namespace ConfigAccess diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx index f572f7136f0d..c56e6979a3a0 100644 --- a/comphelper/source/misc/namedvaluecollection.cxx +++ b/comphelper/source/misc/namedvaluecollection.cxx @@ -24,7 +24,6 @@ #include <com/sun/star/beans/PropertyState.hpp> #include <com/sun/star/beans/PropertyValue.hpp> -#include <rtl/instance.hxx> #include <sal/log.hxx> #include <algorithm> diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx index d94f8485f801..6b9a35ac9a06 100644 --- a/cppu/source/typelib/static_types.cxx +++ b/cppu/source/typelib/static_types.cxx @@ -24,7 +24,6 @@ #include <osl/mutex.hxx> #include <rtl/ustring.hxx> -#include <rtl/instance.hxx> #include <typelib/typedescription.h> #include "typelib.hxx" @@ -32,6 +31,15 @@ using namespace osl; +namespace +{ + Mutex& typelib_StaticInitMutex() + { + static Mutex SINGLETON; + return SINGLETON; + } +} + extern "C" { @@ -88,11 +96,6 @@ static sal_Int32 newAlignedSize( } -namespace -{ - struct typelib_StaticInitMutex : public rtl::Static< Mutex, typelib_StaticInitMutex > {}; -} - // !for NOT REALLY WEAK TYPES only! static typelib_TypeDescriptionReference * igetTypeByName( rtl_uString const * pTypeName ) { @@ -119,7 +122,7 @@ typelib_TypeDescriptionReference ** SAL_CALL typelib_static_type_getByTypeClass( if (! s_aTypes[eTypeClass]) { - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if (! s_aTypes[eTypeClass]) { static const char * s_aTypeNames[] = { @@ -280,7 +283,7 @@ void SAL_CALL typelib_static_type_init( { if (! *ppRef) { - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if (! *ppRef) { OUString aTypeName( OUString::createFromAscii( pTypeName ) ); @@ -300,7 +303,7 @@ void SAL_CALL typelib_static_sequence_type_init( if ( *ppRef) return; - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if ( *ppRef) return; @@ -338,7 +341,7 @@ void init( if ( *ppRef) return; - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if ( *ppRef) return; @@ -452,7 +455,7 @@ void SAL_CALL typelib_static_mi_interface_type_init( if ( *ppRef) return; - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if ( *ppRef) return; @@ -515,7 +518,7 @@ void SAL_CALL typelib_static_enum_type_init( if ( *ppRef) return; - MutexGuard aGuard( typelib_StaticInitMutex::get() ); + MutexGuard aGuard( typelib_StaticInitMutex() ); if ( *ppRef) return; diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx index eadc2c3bdde9..650ac27c3ad9 100644 --- a/cppu/source/typelib/typelib.cxx +++ b/cppu/source/typelib/typelib.cxx @@ -33,7 +33,6 @@ #include <osl/interlck.h> #include <osl/mutex.hxx> #include <rtl/ustring.hxx> -#include <rtl/instance.hxx> #include <osl/diagnose.h> #include <typelib/typedescription.h> #include <uno/any2.h> @@ -273,14 +272,20 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() SAL_INFO_IF( !maCallbacks.empty(), "cppu.typelib", "pCallbacks is not NULL or empty" ); }; -namespace { struct Init : public rtl::Static< TypeDescriptor_Init_Impl, Init > {}; } +namespace { +TypeDescriptor_Init_Impl& Init() +{ + static TypeDescriptor_Init_Impl SINGLETON; + return SINGLETON; +} +} extern "C" void SAL_CALL typelib_typedescription_registerCallback( void * pContext, typelib_typedescription_Callback pCallback ) SAL_THROW_EXTERN_C() { // todo mt safe: guard is no solution, can not acquire while calling callback! - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); // OslGuard aGuard( rInit.getMutex() ); rInit.maCallbacks.push_back( CallbackEntry( pContext, pCallback ) ); } @@ -290,7 +295,7 @@ extern "C" void SAL_CALL typelib_typedescription_revokeCallback( void * pContext, typelib_typedescription_Callback pCallback ) SAL_THROW_EXTERN_C() { - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); { // todo mt safe: guard is no solution, can not acquire while calling callback! // OslGuard aGuard( rInit.getMutex() ); @@ -326,7 +331,7 @@ static void typelib_typedescription_initTables( } } - MutexGuard aGuard( Init::get().maMutex ); + MutexGuard aGuard( Init().maMutex ); if( pTD->bComplete ) return; @@ -406,7 +411,7 @@ bool complete(typelib_TypeDescription ** ppTypeDescr, bool initTables) { typelib_TypeDescription * pTD = nullptr; // on demand access of complete td - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); rInit.callChain( &pTD, (*ppTypeDescr)->pTypeName ); if (pTD) { @@ -493,7 +498,7 @@ extern "C" void typelib_typedescription_newEmpty( auto pTmp = allocTypeDescription<typelib_IndirectTypeDescription>(); pRet = &pTmp->aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nIndirectTypeDescriptionCount ); + osl_atomic_increment( &Init().nIndirectTypeDescriptionCount ); #endif pTmp->pType = nullptr; // coverity[leaked_storage] - this is on purpose @@ -506,7 +511,7 @@ extern "C" void typelib_typedescription_newEmpty( auto pTmp = allocTypeDescription<typelib_StructTypeDescription>(); pRet = &pTmp->aBase.aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nCompoundTypeDescriptionCount ); + osl_atomic_increment( &Init().nCompoundTypeDescriptionCount ); #endif pTmp->aBase.pBaseTypeDescription = nullptr; pTmp->aBase.nMembers = 0; @@ -524,7 +529,7 @@ extern "C" void typelib_typedescription_newEmpty( auto pTmp = allocTypeDescription<typelib_CompoundTypeDescription>(); pRet = &pTmp->aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nCompoundTypeDescriptionCount ); + osl_atomic_increment( &Init().nCompoundTypeDescriptionCount ); #endif pTmp->pBaseTypeDescription = nullptr; pTmp->nMembers = 0; @@ -540,7 +545,7 @@ extern "C" void typelib_typedescription_newEmpty( auto pTmp = allocTypeDescription<typelib_EnumTypeDescription>(); pRet = &pTmp->aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nEnumTypeDescriptionCount ); + osl_atomic_increment( &Init().nEnumTypeDescriptionCount ); #endif pTmp->nDefaultEnumValue = 0; pTmp->nEnumValues = 0; @@ -556,7 +561,7 @@ extern "C" void typelib_typedescription_newEmpty( typelib_InterfaceTypeDescription>(); pRet = &pTmp->aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nInterfaceTypeDescriptionCount ); + osl_atomic_increment( &Init().nInterfaceTypeDescriptionCount ); #endif pTmp->pBaseTypeDescription = nullptr; pTmp->nMembers = 0; @@ -578,7 +583,7 @@ extern "C" void typelib_typedescription_newEmpty( typelib_InterfaceMethodTypeDescription>(); pRet = &pTmp->aBase.aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nInterfaceMethodTypeDescriptionCount ); + osl_atomic_increment( &Init().nInterfaceMethodTypeDescriptionCount ); #endif pTmp->aBase.pMemberName = nullptr; pTmp->pReturnTypeRef = nullptr; @@ -599,7 +604,7 @@ extern "C" void typelib_typedescription_newEmpty( typelib_InterfaceAttributeTypeDescription>(); pRet = &pTmp->aBase.aBase; #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nInterfaceAttributeTypeDescriptionCount ); + osl_atomic_increment( &Init().nInterfaceAttributeTypeDescriptionCount ); #endif pTmp->aBase.pMemberName = nullptr; pTmp->pAttributeTypeRef = nullptr; @@ -618,7 +623,7 @@ extern "C" void typelib_typedescription_newEmpty( { pRet = allocTypeDescription<typelib_TypeDescription>(); #if OSL_DEBUG_LEVEL > 0 - osl_atomic_increment( &Init::get().nTypeDescriptionCount ); + osl_atomic_increment( &Init().nTypeDescriptionCount ); #endif } } @@ -1331,7 +1336,7 @@ extern "C" void SAL_CALL typelib_typedescription_release( if (0 != ref) return; - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); if( TYPELIB_TYPEDESCRIPTIONREFERENCE_ISREALLYWEAK( pTD->eTypeClass ) ) { if( pTD->pWeakRef ) @@ -1395,7 +1400,7 @@ extern "C" void SAL_CALL typelib_typedescription_register( SAL_THROW_EXTERN_C() { // connect the description with the weak reference - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); ClearableMutexGuard aGuard( rInit.maMutex ); typelib_TypeDescriptionReference * pTDR = nullptr; @@ -1873,7 +1878,7 @@ extern "C" void SAL_CALL typelib_typedescription_getByName( } static bool bInited = false; - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); if( !bInited ) { @@ -2049,7 +2054,7 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_new( typelib_TypeClass eTypeClass, rtl_uString * pTypeName ) SAL_THROW_EXTERN_C() { - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); if( eTypeClass == typelib_TypeClass_TYPEDEF ) { // on demand access @@ -2152,7 +2157,7 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_release( { if( ! osl_atomic_decrement( &pRef->nRefCount ) ) { - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); MutexGuard aGuard( rInit.maMutex ); WeakMap_Impl::iterator aIt = rInit.maWeakMap.find( pRef->pTypeName->buffer ); if( aIt != rInit.maWeakMap.end() && (*aIt).second == pRef ) @@ -2195,7 +2200,7 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_getDescription( } { - MutexGuard aGuard( Init::get().maMutex ); + MutexGuard aGuard( Init().maMutex ); // pRef->pType->pWeakRef == 0 means that the description is empty if( pRef->pType && pRef->pType->pWeakRef ) { @@ -2231,7 +2236,7 @@ extern "C" void typelib_typedescriptionreference_getByName( typelib_typedescriptionreference_release( *ppRet ); *ppRet = nullptr; } - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); MutexGuard aGuard( rInit.maMutex ); WeakMap_Impl::const_iterator aIt = rInit.maWeakMap.find( pName->buffer ); @@ -2287,7 +2292,7 @@ extern "C" void SAL_CALL typelib_setCacheSize( sal_Int32 nNewSize ) if (nNewSize < 0) return; - TypeDescriptor_Init_Impl &rInit = Init::get(); + TypeDescriptor_Init_Impl &rInit = Init(); MutexGuard aGuard( rInit.maMutex ); if (nNewSize < nCacheSize) { diff --git a/cppu/source/uno/lbenv.cxx b/cppu/source/uno/lbenv.cxx index 4af07c9d1944..f19d8e725e4f 100644 --- a/cppu/source/uno/lbenv.cxx +++ b/cppu/source/uno/lbenv.cxx @@ -33,7 +33,6 @@ #include <rtl/string.hxx> #include <rtl/ustring.hxx> #include <rtl/ustrbuf.hxx> -#include <rtl/instance.hxx> #include <typelib/typedescription.h> #include <uno/dispatcher.h> #include <uno/environment.h> @@ -127,7 +126,11 @@ struct EnvironmentsData bool isDisposing; }; -struct theEnvironmentsData : public rtl::Static< EnvironmentsData, theEnvironmentsData > {}; +EnvironmentsData& theEnvironmentsData() +{ + static EnvironmentsData SINGLETON; + return SINGLETON; +} struct uno_DefaultEnvironment : public uno_ExtEnvironment { @@ -563,7 +566,7 @@ static void defenv_harden( *ppHardEnv = nullptr; } - EnvironmentsData & rData = theEnvironmentsData::get(); + EnvironmentsData & rData = theEnvironmentsData(); if (rData.isDisposing) return; @@ -1110,7 +1113,7 @@ void SAL_CALL uno_getEnvironment( assert(ppEnv && "### null ptr!"); OUString const & rEnvDcp = OUString::unacquired( &pEnvDcp ); - EnvironmentsData & rData = theEnvironmentsData::get(); + EnvironmentsData & rData = theEnvironmentsData(); ::osl::MutexGuard guard( rData.mutex ); rData.getEnvironment( ppEnv, rEnvDcp, pContext ); @@ -1130,7 +1133,7 @@ void SAL_CALL uno_getRegisteredEnvironments( rtl_uString * pEnvDcp ) SAL_THROW_EXTERN_C() { - EnvironmentsData & rData = theEnvironmentsData::get(); + EnvironmentsData & rData = theEnvironmentsData(); ::osl::MutexGuard guard( rData.mutex ); rData.getRegisteredEnvironments( |