diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-16 19:46:05 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-16 19:53:51 +0100 |
commit | a2bb4fc9174637c065364f9740f164b27172d1f3 (patch) | |
tree | aa2b92c72a8d2faafa12de9137d05d1d9ff56aa7 /sd | |
parent | ae8802cef10c40a40df8f783e724d70618539126 (diff) |
rtl::Static->thread-safe static
Change-Id: I0f39dea1392eb2ba11881615aedbe386870282ee
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125324
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx | 14 | ||||
-rw-r--r-- | sd/source/ui/tools/SdGlobalResourceContainer.cxx | 9 |
2 files changed, 14 insertions, 9 deletions
diff --git a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx index e3a4de5e3a06..d8117d5db145 100644 --- a/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx +++ b/sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx @@ -18,7 +18,6 @@ */ #include "SlsCacheConfiguration.hxx" -#include <rtl/instance.hxx> #include <vcl/svapp.hxx> #include <comphelper/processfactory.hxx> @@ -36,8 +35,11 @@ namespace sd::slidesorter::cache { namespace { typedef std::shared_ptr<CacheConfiguration> CacheConfigSharedPtr; - class theInstance : - public rtl::Static<CacheConfigSharedPtr, theInstance> {}; + CacheConfigSharedPtr& theInstance() + { + static CacheConfigSharedPtr SINGLETON; + return SINGLETON; + } } std::weak_ptr<CacheConfiguration> CacheConfiguration::mpWeakInstance; @@ -45,7 +47,7 @@ std::weak_ptr<CacheConfiguration> CacheConfiguration::mpWeakInstance; std::shared_ptr<CacheConfiguration> CacheConfiguration::Instance() { SolarMutexGuard aSolarGuard; - CacheConfigSharedPtr &rInstancePtr = theInstance::get(); + CacheConfigSharedPtr &rInstancePtr = theInstance(); if (!rInstancePtr) { // Maybe somebody else kept a previously created instance alive. @@ -123,7 +125,7 @@ Any CacheConfiguration::GetValue (const OUString& rName) IMPL_STATIC_LINK_NOARG(CacheConfiguration, TimerCallback, Timer *, void) { - CacheConfigSharedPtr &rInstancePtr = theInstance::get(); + CacheConfigSharedPtr &rInstancePtr = theInstance(); // Release our reference to the instance. rInstancePtr.reset(); // note: if there are no other references to the instance, m_ReleaseTimer @@ -132,7 +134,7 @@ IMPL_STATIC_LINK_NOARG(CacheConfiguration, TimerCallback, Timer *, void) void CacheConfiguration::Shutdown() { - CacheConfigSharedPtr &rInstancePtr = theInstance::get(); + CacheConfigSharedPtr &rInstancePtr = theInstance(); rInstancePtr.reset(); assert(mpWeakInstance.expired()); // ensure m_ReleaseTimer is destroyed } diff --git a/sd/source/ui/tools/SdGlobalResourceContainer.cxx b/sd/source/ui/tools/SdGlobalResourceContainer.cxx index da46c1d98672..a7dbc5f25920 100644 --- a/sd/source/ui/tools/SdGlobalResourceContainer.cxx +++ b/sd/source/ui/tools/SdGlobalResourceContainer.cxx @@ -26,7 +26,6 @@ #include <com/sun/star/frame/Desktop.hpp> -#include <rtl/instance.hxx> #include <sal/log.hxx> #include <tools/debug.hxx> @@ -53,7 +52,11 @@ public: namespace { -struct theSdGlobalResourceContainerInstance : public rtl::Static<SdGlobalResourceContainerInstance, theSdGlobalResourceContainerInstance> {}; +SdGlobalResourceContainerInstance& theSdGlobalResourceContainerInstance() +{ + static SdGlobalResourceContainerInstance SINGLETON; + return SINGLETON; +} } // namespace @@ -81,7 +84,7 @@ private: // static SdGlobalResourceContainer& SdGlobalResourceContainer::Instance() { - SdGlobalResourceContainer *const pRet(theSdGlobalResourceContainerInstance::get().get()); + SdGlobalResourceContainer *const pRet(theSdGlobalResourceContainerInstance().get()); assert(pRet); // error if it has been deleted and is null return *pRet; } |