diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-18 19:53:25 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-19 07:32:43 +0100 |
commit | 79db82976e3070b7889d2ec350dde3eff703ebe4 (patch) | |
tree | 440c0b5266c46df0f8c676ab3f98a44c5ea6dae0 | |
parent | 11800469cc7b3a40c42410be93a12e5107db0efb (diff) |
rtl::Static->thread-safe static in svtools
Change-Id: I437259b4a70ec575e937821b9b1adc001723f29c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125492
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r-- | svtools/source/config/accessibilityoptions.cxx | 12 | ||||
-rw-r--r-- | svtools/source/config/colorcfg.cxx | 12 | ||||
-rw-r--r-- | svtools/source/config/extcolorcfg.cxx | 12 | ||||
-rw-r--r-- | svtools/source/config/miscopt.cxx | 10 | ||||
-rw-r--r-- | svtools/source/config/slidesorterbaropt.cxx | 10 | ||||
-rw-r--r-- | svtools/source/control/inettbc.cxx | 14 |
6 files changed, 33 insertions, 37 deletions
diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx index 7debdf47327e..05c113478402 100644 --- a/svtools/source/config/accessibilityoptions.cxx +++ b/svtools/source/config/accessibilityoptions.cxx @@ -30,7 +30,6 @@ #include <vcl/settings.hxx> #include <vcl/svapp.hxx> -#include <rtl/instance.hxx> #include <tools/diagnose_ex.h> #include "itemholder2.hxx" @@ -71,8 +70,11 @@ sal_Int32 SvtAccessibilityOptions::sm_nAccessibilityRefCount namespace { - struct SingletonMutex - : public rtl::Static< ::osl::Mutex, SingletonMutex > {}; + ::osl::Mutex& SingletonMutex() + { + static ::osl::Mutex SINGLETON; + return SINGLETON; + } } @@ -335,7 +337,7 @@ SvtAccessibilityOptions::SvtAccessibilityOptions() { if (!utl::ConfigManager::IsFuzzing()) { - ::osl::MutexGuard aGuard( SingletonMutex::get() ); + ::osl::MutexGuard aGuard( SingletonMutex() ); if(!sm_pSingleImplConfig) { sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl; @@ -349,7 +351,7 @@ SvtAccessibilityOptions::SvtAccessibilityOptions() SvtAccessibilityOptions::~SvtAccessibilityOptions() { //EndListening( *sm_pSingleImplConfig, sal_True ); - ::osl::MutexGuard aGuard( SingletonMutex::get() ); + ::osl::MutexGuard aGuard( SingletonMutex() ); if( !--sm_nAccessibilityRefCount ) { //if( sm_pSingleImplConfig->IsModified() ) diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index ec918014e98f..f72736afe6cb 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -39,7 +39,6 @@ #include <vcl/svapp.hxx> #include <vcl/event.hxx> #include <vcl/settings.hxx> -#include <rtl/instance.hxx> using namespace utl; @@ -54,8 +53,11 @@ namespace svtools static sal_Int32 nColorRefCount_Impl = 0; namespace { - struct ColorMutex_Impl - : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {}; + ::osl::Mutex& ColorMutex_Impl() + { + static ::osl::Mutex SINGLETON; + return SINGLETON; + } } ColorConfig_Impl* ColorConfig::m_pImpl = nullptr; @@ -376,7 +378,7 @@ ColorConfig::ColorConfig() { if (utl::ConfigManager::IsFuzzing()) return; - ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + ::osl::MutexGuard aGuard( ColorMutex_Impl() ); if ( !m_pImpl ) { m_pImpl = new ColorConfig_Impl; @@ -390,7 +392,7 @@ ColorConfig::~ColorConfig() { if (utl::ConfigManager::IsFuzzing()) return; - ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + ::osl::MutexGuard aGuard( ColorMutex_Impl() ); m_pImpl->RemoveListener(this); if(!--nColorRefCount_Impl) { diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index e5767b0b1453..bdeda2d4e8b9 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -38,7 +38,6 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> #include <vcl/event.hxx> -#include <rtl/instance.hxx> using namespace utl; @@ -51,8 +50,11 @@ namespace svtools static sal_Int32 nExtendedColorRefCount_Impl = 0; namespace { - struct ColorMutex_Impl - : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {}; + ::osl::Mutex& ColorMutex_Impl() + { + static ::osl::Mutex SINGLETON; + return SINGLETON; + } } ExtendedColorConfig_Impl* ExtendedColorConfig::m_pImpl = nullptr; @@ -506,7 +508,7 @@ IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclSimpleEvent&, ExtendedColorConfig::ExtendedColorConfig() { - ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + ::osl::MutexGuard aGuard( ColorMutex_Impl() ); if ( !m_pImpl ) m_pImpl = new ExtendedColorConfig_Impl; ++nExtendedColorRefCount_Impl; @@ -515,7 +517,7 @@ ExtendedColorConfig::ExtendedColorConfig() ExtendedColorConfig::~ExtendedColorConfig() { - ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + ::osl::MutexGuard aGuard( ColorMutex_Impl() ); EndListening( *m_pImpl); if(!--nExtendedColorRefCount_Impl) { diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx index 1da6ba473eba..9c154b92dbc4 100644 --- a/svtools/source/config/miscopt.cxx +++ b/svtools/source/config/miscopt.cxx @@ -26,7 +26,6 @@ #include <tools/link.hxx> #include <osl/diagnose.h> -#include <rtl/instance.hxx> #include "itemholder2.hxx" #include <svtools/imgdef.hxx> @@ -429,15 +428,10 @@ void SvtMiscOptions::SetIconTheme(const OUString& iconTheme) m_pImpl->SetIconTheme(iconTheme, SvtMiscOptions_Impl::SetModifiedFlag::SET); } -namespace -{ - class theSvtMiscOptionsMutex : - public rtl::Static< osl::Mutex, theSvtMiscOptionsMutex > {}; -} - Mutex & SvtMiscOptions::GetInitMutex() { - return theSvtMiscOptionsMutex::get(); + static osl::Mutex theSvtMiscOptionsMutex; + return theSvtMiscOptionsMutex; } void SvtMiscOptions::AddListenerLink( const Link<LinkParamNone*,void>& rLink ) diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx index 1ff23bcaed34..f2e3c5d108dd 100644 --- a/svtools/source/config/slidesorterbaropt.cxx +++ b/svtools/source/config/slidesorterbaropt.cxx @@ -26,7 +26,6 @@ #include <comphelper/lok.hxx> #include <comphelper/sequence.hxx> -#include <rtl/instance.hxx> using namespace ::utl; using namespace ::osl; @@ -418,15 +417,10 @@ void SvtSlideSorterBarOptions::SetVisibleDrawView(bool bVisible) m_pImpl->SetVisibleDrawView( bVisible ); } -namespace -{ - class theSvtSlideSorterBarOptionsMutex : - public rtl::Static< osl::Mutex, theSvtSlideSorterBarOptionsMutex > {}; -} - Mutex & SvtSlideSorterBarOptions::GetInitMutex() { - return theSvtSlideSorterBarOptionsMutex::get(); + static osl::Mutex theSvtSlideSorterBarOptionsMutex; + return theSvtSlideSorterBarOptionsMutex; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index 147ce77a4b14..6a811a5f0af6 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -39,7 +39,6 @@ #include <com/sun/star/ucb/SortedDynamicResultSetFactory.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/string.hxx> -#include <rtl/instance.hxx> #include <salhelper/thread.hxx> #include <tools/debug.hxx> #include <osl/file.hxx> @@ -114,8 +113,11 @@ public: namespace { - struct theSvtMatchContextMutex - : public rtl::Static< ::osl::Mutex, theSvtMatchContextMutex > {}; + ::osl::Mutex& theSvtMatchContextMutex() + { + static ::osl::Mutex SINGLETON; + return SINGLETON; + } } SvtMatchContext_Impl::SvtMatchContext_Impl(SvtURLBox* pBoxP, const OUString& rText) @@ -400,7 +402,7 @@ void SvtMatchContext_Impl::ReadFolder( const OUString& rURL, void SvtMatchContext_Impl::doExecute() { - ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() ); + ::osl::MutexGuard aGuard( theSvtMatchContextMutex() ); { // have we been stopped while we were waiting for the mutex? std::scoped_lock g(mutex_); @@ -987,7 +989,7 @@ void SvtURLBox::SetNoURLSelection( bool bSet ) OUString SvtURLBox::GetURL() { // wait for end of autocompletion - ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() ); + ::osl::MutexGuard aGuard( theSvtMatchContextMutex() ); OUString aText(m_xWidget->get_active_text()); if (MatchesPlaceHolder(aText)) @@ -1062,7 +1064,7 @@ OUString SvtURLBox::GetURL() void SvtURLBox::SetBaseURL( const OUString& rURL ) { - ::osl::MutexGuard aGuard( theSvtMatchContextMutex::get() ); + ::osl::MutexGuard aGuard( theSvtMatchContextMutex() ); // Reset match lists pImpl->aCompletions.clear(); |