include/comphelper/proparrhlp.hxx | 16 ++++++++-------- include/comphelper/servicehelper.hxx | 1 - 2 files changed, 8 insertions(+), 9 deletions(-)
New commits: commit ec1a54ca6033533a20309f3df5b8b5353bb2b509 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Thu Nov 11 20:55:22 2021 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Sat Nov 13 07:35:10 2021 +0100 rtl::Static->thread-safe static in OPropertyArrayUsageHelper Change-Id: I389aed33ec3f814c30fca438ac36af4292b30388 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125118 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/include/comphelper/proparrhlp.hxx b/include/comphelper/proparrhlp.hxx index a53b718c2697..8520ac58f87d 100644 --- a/include/comphelper/proparrhlp.hxx +++ b/include/comphelper/proparrhlp.hxx @@ -24,21 +24,21 @@ #include <cppuhelper/propshlp.hxx> #include <osl/mutex.hxx> #include <osl/diagnose.h> -#include <rtl/instance.hxx> namespace comphelper { -template <typename TYPE> struct OPropertyArrayUsageHelperMutex - : public rtl::Static< ::osl::Mutex, OPropertyArrayUsageHelperMutex<TYPE> > {}; - template <class TYPE> class OPropertyArrayUsageHelper { protected: static sal_Int32 s_nRefCount; static ::cppu::IPropertyArrayHelper* s_pProps; - + static osl::Mutex& theMutex() + { + static osl::Mutex SINGLETON; + return SINGLETON; + } public: OPropertyArrayUsageHelper(); virtual ~OPropertyArrayUsageHelper(); @@ -92,14 +92,14 @@ template<class TYPE> template <class TYPE> OPropertyArrayUsageHelper<TYPE>::OPropertyArrayUsageHelper() { - ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get()); + ::osl::MutexGuard aGuard(theMutex()); ++s_nRefCount; } template <class TYPE> OPropertyArrayUsageHelper<TYPE>::~OPropertyArrayUsageHelper() { - ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get()); + ::osl::MutexGuard aGuard(theMutex()); OSL_ENSURE(s_nRefCount > 0, "OPropertyArrayUsageHelper::~OPropertyArrayUsageHelper : suspicious call : have a refcount of 0 !"); if (!--s_nRefCount) { @@ -114,7 +114,7 @@ template <class TYPE> OSL_ENSURE(s_nRefCount, "OPropertyArrayUsageHelper::getArrayHelper : suspicious call : have a refcount of 0 !"); if (!s_pProps) { - ::osl::MutexGuard aGuard(OPropertyArrayUsageHelperMutex<TYPE>::get()); + ::osl::MutexGuard aGuard(theMutex()); if (!s_pProps) { s_pProps = createArrayHelper(); diff --git a/include/comphelper/servicehelper.hxx b/include/comphelper/servicehelper.hxx index fa906075e1b6..b2c6bf46d009 100644 --- a/include/comphelper/servicehelper.hxx +++ b/include/comphelper/servicehelper.hxx @@ -21,7 +21,6 @@ #define INCLUDED_COMPHELPER_SERVICEHELPER_HXX #include <rtl/uuid.h> -#include <rtl/instance.hxx> #include <com/sun/star/lang/XUnoTunnel.hpp> #include <com/sun/star/uno/Sequence.hxx>