diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-12-20 21:08:31 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-01 20:21:09 +0100 |
commit | bf44ea9d2daea4a57d7add7d2d81c8309d659bb2 (patch) | |
tree | 8bd74cdfcbc05396c7d5d9593851d4cee55f11fc /svtools | |
parent | 98dbb1b50af57b3070da6434825e79747f536f8a (diff) |
osl::Mutex->std::mutex in Svt*Options
Change-Id: I329849310f289e0fe7a886bbf3855f8d569767c0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127830
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/config/accessibilityoptions.cxx | 10 | ||||
-rw-r--r-- | svtools/source/config/colorcfg.cxx | 11 | ||||
-rw-r--r-- | svtools/source/config/extcolorcfg.cxx | 10 | ||||
-rw-r--r-- | svtools/source/config/miscopt.cxx | 19 | ||||
-rw-r--r-- | svtools/source/config/slidesorterbaropt.cxx | 18 |
5 files changed, 38 insertions, 30 deletions
diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx index 05c113478402..4922326fa0f0 100644 --- a/svtools/source/config/accessibilityoptions.cxx +++ b/svtools/source/config/accessibilityoptions.cxx @@ -31,6 +31,7 @@ #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <tools/diagnose_ex.h> +#include <mutex> #include "itemholder2.hxx" @@ -70,9 +71,9 @@ sal_Int32 SvtAccessibilityOptions::sm_nAccessibilityRefCount namespace { - ::osl::Mutex& SingletonMutex() + std::mutex& SingletonMutex() { - static ::osl::Mutex SINGLETON; + static std::mutex SINGLETON; return SINGLETON; } } @@ -337,10 +338,11 @@ SvtAccessibilityOptions::SvtAccessibilityOptions() { if (!utl::ConfigManager::IsFuzzing()) { - ::osl::MutexGuard aGuard( SingletonMutex() ); + std::unique_lock aGuard( SingletonMutex() ); if(!sm_pSingleImplConfig) { sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl; + aGuard.unlock(); // because holdConfigItem will call this constructor svtools::ItemHolder2::holdConfigItem(EItem::AccessibilityOptions); } ++sm_nAccessibilityRefCount; @@ -351,7 +353,7 @@ SvtAccessibilityOptions::SvtAccessibilityOptions() SvtAccessibilityOptions::~SvtAccessibilityOptions() { //EndListening( *sm_pSingleImplConfig, sal_True ); - ::osl::MutexGuard aGuard( SingletonMutex() ); + std::unique_lock aGuard( SingletonMutex() ); if( !--sm_nAccessibilityRefCount ) { //if( sm_pSingleImplConfig->IsModified() ) diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx index f72736afe6cb..3bbd37f6c9ce 100644 --- a/svtools/source/config/colorcfg.cxx +++ b/svtools/source/config/colorcfg.cxx @@ -32,7 +32,7 @@ #include <unotools/configpaths.hxx> #include <com/sun/star/uno/Sequence.h> #include <svl/poolitem.hxx> -#include <osl/mutex.hxx> +#include <mutex> #include "itemholder2.hxx" @@ -53,9 +53,9 @@ namespace svtools static sal_Int32 nColorRefCount_Impl = 0; namespace { - ::osl::Mutex& ColorMutex_Impl() + std::mutex& ColorMutex_Impl() { - static ::osl::Mutex SINGLETON; + static std::mutex SINGLETON; return SINGLETON; } } @@ -378,10 +378,11 @@ ColorConfig::ColorConfig() { if (utl::ConfigManager::IsFuzzing()) return; - ::osl::MutexGuard aGuard( ColorMutex_Impl() ); + std::unique_lock aGuard( ColorMutex_Impl() ); if ( !m_pImpl ) { m_pImpl = new ColorConfig_Impl; + aGuard.unlock(); // because holdConfigItem will call this constructor svtools::ItemHolder2::holdConfigItem(EItem::ColorConfig); } ++nColorRefCount_Impl; @@ -392,7 +393,7 @@ ColorConfig::~ColorConfig() { if (utl::ConfigManager::IsFuzzing()) return; - ::osl::MutexGuard aGuard( ColorMutex_Impl() ); + std::unique_lock 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 bdeda2d4e8b9..2ad876b110f1 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -31,7 +31,7 @@ #include <com/sun/star/uno/Sequence.h> #include <comphelper/sequence.hxx> #include <svl/hint.hxx> -#include <osl/mutex.hxx> +#include <mutex> #include <sal/log.hxx> #include <osl/diagnose.h> @@ -50,9 +50,9 @@ namespace svtools static sal_Int32 nExtendedColorRefCount_Impl = 0; namespace { - ::osl::Mutex& ColorMutex_Impl() + std::mutex& ColorMutex_Impl() { - static ::osl::Mutex SINGLETON; + static std::mutex SINGLETON; return SINGLETON; } } @@ -508,7 +508,7 @@ IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclSimpleEvent&, ExtendedColorConfig::ExtendedColorConfig() { - ::osl::MutexGuard aGuard( ColorMutex_Impl() ); + std::unique_lock aGuard( ColorMutex_Impl() ); if ( !m_pImpl ) m_pImpl = new ExtendedColorConfig_Impl; ++nExtendedColorRefCount_Impl; @@ -517,7 +517,7 @@ ExtendedColorConfig::ExtendedColorConfig() ExtendedColorConfig::~ExtendedColorConfig() { - ::osl::MutexGuard aGuard( ColorMutex_Impl() ); + std::unique_lock aGuard( ColorMutex_Impl() ); EndListening( *m_pImpl); if(!--nExtendedColorRefCount_Impl) { diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx index 9c154b92dbc4..2462a5804659 100644 --- a/svtools/source/config/miscopt.cxx +++ b/svtools/source/config/miscopt.cxx @@ -32,6 +32,7 @@ #include <vcl/svapp.hxx> #include <vcl/settings.hxx> +#include <mutex> #include <vector> using namespace ::utl ; @@ -47,6 +48,13 @@ constexpr OUStringLiteral PROPERTYNAME_SYMBOLSET = u"SymbolSet"; constexpr OUStringLiteral PROPERTYNAME_ICONTHEME = u"SymbolStyle"; #define PROPERTYHANDLE_SYMBOLSTYLE 1 +static std::mutex & GetInitMutex() +{ + static std::mutex theSvtMiscOptionsMutex; + return theSvtMiscOptionsMutex; +} + + class SvtMiscOptions_Impl : public ConfigItem { private: @@ -363,13 +371,14 @@ std::weak_ptr<SvtMiscOptions_Impl> g_pMiscOptions; SvtMiscOptions::SvtMiscOptions() { // Global access, must be guarded (multithreading!). - MutexGuard aGuard( GetInitMutex() ); + std::unique_lock aGuard( GetInitMutex() ); m_pImpl = g_pMiscOptions.lock(); if( !m_pImpl ) { m_pImpl = std::make_shared<SvtMiscOptions_Impl>(); g_pMiscOptions = m_pImpl; + aGuard.unlock(); // because holdConfigItem will call this constructor svtools::ItemHolder2::holdConfigItem(EItem::MiscOptions); } } @@ -377,7 +386,7 @@ SvtMiscOptions::SvtMiscOptions() SvtMiscOptions::~SvtMiscOptions() { // Global access, must be guarded (multithreading!) - MutexGuard aGuard( GetInitMutex() ); + std::unique_lock aGuard( GetInitMutex() ); m_pImpl.reset(); } @@ -428,12 +437,6 @@ void SvtMiscOptions::SetIconTheme(const OUString& iconTheme) m_pImpl->SetIconTheme(iconTheme, SvtMiscOptions_Impl::SetModifiedFlag::SET); } -Mutex & SvtMiscOptions::GetInitMutex() -{ - static osl::Mutex theSvtMiscOptionsMutex; - return theSvtMiscOptionsMutex; -} - void SvtMiscOptions::AddListenerLink( const Link<LinkParamNone*,void>& rLink ) { m_pImpl->AddListenerLink( rLink ); diff --git a/svtools/source/config/slidesorterbaropt.cxx b/svtools/source/config/slidesorterbaropt.cxx index 22b5b6b5e768..784e0894ef27 100644 --- a/svtools/source/config/slidesorterbaropt.cxx +++ b/svtools/source/config/slidesorterbaropt.cxx @@ -26,6 +26,7 @@ #include <comphelper/lok.hxx> #include <comphelper/sequence.hxx> +#include <mutex> using namespace ::utl; using namespace ::osl; @@ -47,6 +48,13 @@ constexpr OUStringLiteral PROPERTYNAME_VISIBLE_SLIDESORTERVIEW = u"SlideSorterVi constexpr OUStringLiteral PROPERTYNAME_VISIBLE_DRAWVIEW = u"DrawView"; #define PROPERTYHANDLE_VISIBLE_DRAWVIEW 5 +static std::mutex & GetInitMutex() +{ + static std::mutex theSvtSlideSorterBarOptionsMutex; + return theSvtSlideSorterBarOptionsMutex; +} + + class SvtSlideSorterBarOptions_Impl : public ConfigItem { Sequence< OUString > m_seqPropertyNames; @@ -335,7 +343,7 @@ namespace { SvtSlideSorterBarOptions::SvtSlideSorterBarOptions() { // Global access, must be guarded (multithreading!). - MutexGuard aGuard( GetInitMutex() ); + std::unique_lock aGuard( GetInitMutex() ); m_pImpl = g_pSlideSorterBarOptions.lock(); if( !m_pImpl ) @@ -348,7 +356,7 @@ SvtSlideSorterBarOptions::SvtSlideSorterBarOptions() SvtSlideSorterBarOptions::~SvtSlideSorterBarOptions() { // Global access, must be guarded (multithreading!) - MutexGuard aGuard( GetInitMutex() ); + std::unique_lock aGuard( GetInitMutex() ); m_pImpl.reset(); } @@ -414,10 +422,4 @@ void SvtSlideSorterBarOptions::SetVisibleDrawView(bool bVisible) m_pImpl->SetVisibleDrawView( bVisible ); } -Mutex & SvtSlideSorterBarOptions::GetInitMutex() -{ - static osl::Mutex theSvtSlideSorterBarOptionsMutex; - return theSvtSlideSorterBarOptionsMutex; -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |