diff options
-rw-r--r-- | comphelper/source/misc/compbase.cxx | 6 | ||||
-rw-r--r-- | cppuhelper/source/compbase.cxx | 6 | ||||
-rw-r--r-- | cppuhelper/source/implbase_ex.cxx | 6 |
3 files changed, 18 insertions, 0 deletions
diff --git a/comphelper/source/misc/compbase.cxx b/comphelper/source/misc/compbase.cxx index 02efae8b71c45..eafabb0139370 100644 --- a/comphelper/source/misc/compbase.cxx +++ b/comphelper/source/misc/compbase.cxx @@ -97,6 +97,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1, static cppu::type_entry* getTypeEntries(cppu::class_data* cd) { cppu::type_entry* pEntries = cd->m_typeEntries; + if (!cd->m_storedTypeRefs) // not inited? { static std::mutex aMutex; std::scoped_lock guard(aMutex); @@ -121,9 +122,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd) // ref is statically held by getCppuType() pEntry->m_type.typeRef = rType.getTypeLibType(); } + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); cd->m_storedTypeRefs = true; } } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } return pEntries; } diff --git a/cppuhelper/source/compbase.cxx b/cppuhelper/source/compbase.cxx index aca77677a0f4a..ed4909b711069 100644 --- a/cppuhelper/source/compbase.cxx +++ b/cppuhelper/source/compbase.cxx @@ -81,6 +81,7 @@ static bool td_equals(typelib_TypeDescriptionReference const* pTDR1, static cppu::type_entry* getTypeEntries(cppu::class_data* cd) { cppu::type_entry* pEntries = cd->m_typeEntries; + if (!cd->m_storedTypeRefs) // not inited? { static std::mutex aMutex; std::scoped_lock guard(aMutex); @@ -105,9 +106,14 @@ static cppu::type_entry* getTypeEntries(cppu::class_data* cd) // ref is statically held by getCppuType() pEntry->m_type.typeRef = rType.getTypeLibType(); } + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); cd->m_storedTypeRefs = true; } } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } return pEntries; } diff --git a/cppuhelper/source/implbase_ex.cxx b/cppuhelper/source/implbase_ex.cxx index 9d3e034127371..3f88feb97dd1f 100644 --- a/cppuhelper/source/implbase_ex.cxx +++ b/cppuhelper/source/implbase_ex.cxx @@ -64,6 +64,7 @@ static bool td_equals( static type_entry * getTypeEntries( class_data * cd ) { type_entry * pEntries = cd->m_typeEntries; + if (! cd->m_storedTypeRefs) // not inited? { static std::mutex aMutex; std::scoped_lock guard( aMutex ); @@ -85,9 +86,14 @@ static type_entry * getTypeEntries( class_data * cd ) // ref is statically held by getCppuType() pEntry->m_type.typeRef = rType.getTypeLibType(); } + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); cd->m_storedTypeRefs = true; } } + else + { + OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER(); + } return pEntries; } |