diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-17 20:42:45 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-18 14:17:21 +0100 |
commit | ed6651ec3b5dafed759cb602ad25e150592693a9 (patch) | |
tree | 9c4427de09a7ca8af8fe383f38f1a33df0d572f6 /svl | |
parent | 3f12e3e992ae307886bc73ff37f07b270701730e (diff) |
rtl::Static->thread-safe static in svl
Change-Id: Idadc4dc77eb681a8b8923ffacf37ddbe1d8245e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125425
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/config/ctloptions.cxx | 27 | ||||
-rw-r--r-- | svl/source/config/languageoptions.cxx | 1 | ||||
-rw-r--r-- | svl/source/misc/urihelper.cxx | 1 | ||||
-rw-r--r-- | svl/source/numbers/zforlist.cxx | 27 | ||||
-rw-r--r-- | svl/unx/source/svdde/ddedummy.cxx | 10 |
5 files changed, 32 insertions, 34 deletions
diff --git a/svl/source/config/ctloptions.cxx b/svl/source/config/ctloptions.cxx index 0723f47ac1a1..38544f758a3a 100644 --- a/svl/source/config/ctloptions.cxx +++ b/svl/source/config/ctloptions.cxx @@ -24,7 +24,6 @@ #include <com/sun/star/uno/Any.h> #include <com/sun/star/uno/Sequence.hxx> #include <osl/mutex.hxx> -#include <rtl/instance.hxx> #include "itemholder2.hxx" using namespace ::com::sun::star; @@ -84,8 +83,11 @@ public: }; namespace { - struct PropertyNames - : public rtl::Static< Sequence< OUString >, PropertyNames > {}; + Sequence<OUString> & PropertyNames() + { + static Sequence<OUString> SINGLETON; + return SINGLETON; + } } bool SvtCTLOptions_Impl::IsReadOnly(SvtCTLOptions::EOption eOption) const { @@ -135,7 +137,7 @@ void SvtCTLOptions_Impl::Notify( const Sequence< OUString >& ) void SvtCTLOptions_Impl::ImplCommit() { - Sequence< OUString > &rPropertyNames = PropertyNames::get(); + Sequence< OUString > &rPropertyNames = PropertyNames(); OUString* pOrgNames = rPropertyNames.getArray(); sal_Int32 nOrgCount = rPropertyNames.getLength(); @@ -225,17 +227,16 @@ void SvtCTLOptions_Impl::ImplCommit() void SvtCTLOptions_Impl::Load() { - Sequence< OUString >& rPropertyNames = PropertyNames::get(); + Sequence< OUString >& rPropertyNames = PropertyNames(); if ( !rPropertyNames.hasElements() ) { - rPropertyNames.realloc(6); - OUString* pNames = rPropertyNames.getArray(); - pNames[0] = "CTLFont"; - pNames[1] = "CTLSequenceChecking"; - pNames[2] = "CTLCursorMovement"; - pNames[3] = "CTLTextNumerals"; - pNames[4] = "CTLSequenceCheckingRestricted"; - pNames[5] = "CTLSequenceCheckingTypeAndReplace"; + rPropertyNames = { + "CTLFont", + "CTLSequenceChecking", + "CTLCursorMovement", + "CTLTextNumerals", + "CTLSequenceCheckingRestricted", + "CTLSequenceCheckingTypeAndReplace" }; EnableNotification( rPropertyNames ); } Sequence< Any > aValues = GetProperties( rPropertyNames ); diff --git a/svl/source/config/languageoptions.cxx b/svl/source/config/languageoptions.cxx index 2e7550b98758..b7159fd2c063 100644 --- a/svl/source/config/languageoptions.cxx +++ b/svl/source/config/languageoptions.cxx @@ -23,7 +23,6 @@ #include <svl/ctloptions.hxx> #include <i18nlangtag/mslangid.hxx> #include <i18nlangtag/languagetag.hxx> -#include <rtl/instance.hxx> #include <com/sun/star/i18n/ScriptType.hpp> #include <unotools/syslocale.hxx> #include <com/sun/star/uno/Any.hxx> diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index c945c1f2e3e5..6792fc1d77f7 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -44,7 +44,6 @@ #include <comphelper/processfactory.hxx> #include <osl/diagnose.h> #include <rtl/character.hxx> -#include <rtl/instance.hxx> #include <rtl/ustrbuf.hxx> #include <rtl/ustring.hxx> #include <sal/types.h> diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 8e90067a47b8..fbd05a481df9 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -48,7 +48,6 @@ #include <unotools/syslocaleoptions.hxx> #include <unotools/digitgroupingiterator.hxx> -#include <rtl/instance.hxx> #include <rtl/strbuf.hxx> #include <rtl/math.hxx> @@ -248,11 +247,17 @@ SvNumberFormatterRegistry_Impl* SvNumberFormatter::pFormatterRegistry = nullptr; volatile bool SvNumberFormatter::bCurrencyTableInitialized = false; namespace { - struct theCurrencyTable : - public rtl::Static< NfCurrencyTable, theCurrencyTable > {}; + NfCurrencyTable& theCurrencyTable() + { + static NfCurrencyTable SINGLETON; + return SINGLETON; + } - struct theLegacyOnlyCurrencyTable : - public rtl::Static< NfCurrencyTable, theLegacyOnlyCurrencyTable > {}; + NfCurrencyTable& theLegacyOnlyCurrencyTable() + { + static NfCurrencyTable SINGLETON; + return SINGLETON; + } /** THE set of installed locales. */ std::set< LanguageType > theInstalledLocales; @@ -3633,7 +3638,7 @@ const NfCurrencyTable& SvNumberFormatter::GetTheCurrencyTable() { while ( !bCurrencyTableInitialized ) ImpInitCurrencyTable(); - return theCurrencyTable::get(); + return theCurrencyTable(); } @@ -3692,7 +3697,7 @@ const NfCurrencyEntry* SvNumberFormatter::GetLegacyOnlyCurrencyEntry( std::u16st std::u16string_view rAbbrev ) { GetTheCurrencyTable(); // just for initialization - const NfCurrencyTable& rTable = theLegacyOnlyCurrencyTable::get(); + const NfCurrencyTable& rTable = theLegacyOnlyCurrencyTable(); sal_uInt16 nCount = rTable.size(); for ( sal_uInt16 j = 0; j < nCount; j++ ) { @@ -4144,16 +4149,16 @@ void SvNumberFormatter::ImpInitCurrencyTable() sal_uInt16 nMatchingSystemCurrencyPosition = 0; // First entry is SYSTEM: - theCurrencyTable::get().insert( - theCurrencyTable::get().begin(), + auto& rCurrencyTable = theCurrencyTable(); + rCurrencyTable.insert( + rCurrencyTable.begin(), NfCurrencyEntry(*pLocaleData, LANGUAGE_SYSTEM)); sal_uInt16 nCurrencyPos = 1; const css::uno::Sequence< css::lang::Locale > xLoc = LocaleDataWrapper::getInstalledLocaleNames(); sal_Int32 nLocaleCount = xLoc.getLength(); SAL_INFO( "svl.numbers", "number of locales: \"" << nLocaleCount << "\"" ); - NfCurrencyTable &rCurrencyTable = theCurrencyTable::get(); - NfCurrencyTable &rLegacyOnlyCurrencyTable = theLegacyOnlyCurrencyTable::get(); + NfCurrencyTable &rLegacyOnlyCurrencyTable = theLegacyOnlyCurrencyTable(); sal_uInt16 nLegacyOnlyCurrencyPos = 0; for ( css::lang::Locale const & rLocale : xLoc ) { diff --git a/svl/unx/source/svdde/ddedummy.cxx b/svl/unx/source/svdde/ddedummy.cxx index 03e423d47b3f..e174e0bc4ae1 100644 --- a/svl/unx/source/svdde/ddedummy.cxx +++ b/svl/unx/source/svdde/ddedummy.cxx @@ -18,7 +18,6 @@ */ #include <svl/svdde.hxx> -#include <rtl/instance.hxx> #include <tools/long.hxx> struct Conversation @@ -250,15 +249,10 @@ OUString DdeService::GetName() const return OUString(); } -namespace -{ - struct theDdeServices - : public rtl::Static< DdeServices, theDdeServices > {}; -} - DdeServices& DdeService::GetServices() { - return theDdeServices::get(); + static DdeServices SINGLETON; + return SINGLETON; } DdeItem::DdeItem( SAL_UNUSED_PARAMETER const OUString& ) |