salhelper/source/timer.cxx                               |    1 -
 sc/source/ui/vba/vbaapplication.cxx                      |   11 +++++++----
 sd/source/ui/slidesorter/cache/SlsCacheConfiguration.cxx |   14 ++++++++------
 sd/source/ui/tools/SdGlobalResourceContainer.cxx         |    9 ++++++---
 4 files changed, 21 insertions(+), 14 deletions(-)

New commits:
commit a2bb4fc9174637c065364f9740f164b27172d1f3
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Tue Nov 16 19:46:05 2021 +0200
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Tue Nov 16 19:53:51 2021 +0100

    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.gran...@collabora.co.uk>

diff --git a/salhelper/source/timer.cxx b/salhelper/source/timer.cxx
index 430cdfe9138c..c0fba72ed68f 100644
--- a/salhelper/source/timer.cxx
+++ b/salhelper/source/timer.cxx
@@ -21,7 +21,6 @@
 #include <osl/thread.hxx>
 #include <osl/conditn.hxx>
 #include <osl/mutex.hxx>
-#include <rtl/instance.hxx>
 
 #include <mutex>
 
diff --git a/sc/source/ui/vba/vbaapplication.cxx 
b/sc/source/ui/vba/vbaapplication.cxx
index 7c6e56dbf529..01885a36f0e3 100644
--- a/sc/source/ui/vba/vbaapplication.cxx
+++ b/sc/source/ui/vba/vbaapplication.cxx
@@ -57,7 +57,6 @@
 #include "vbafiledialog.hxx"
 
 #include <osl/file.hxx>
-#include <rtl/instance.hxx>
 
 #include <sfx2/bindings.hxx>
 #include <sfx2/request.hxx>
@@ -117,7 +116,11 @@ ScVbaAppSettings::ScVbaAppSettings() :
 
 namespace {
 
-struct ScVbaStaticAppSettings : public ::rtl::Static< ScVbaAppSettings, 
ScVbaStaticAppSettings > {};
+ScVbaAppSettings& ScVbaStaticAppSettings()
+{
+    static ScVbaAppSettings SINGLETON;
+    return SINGLETON;
+}
 
 class ScVbaApplicationOutgoingConnectionPoint : public 
cppu::WeakImplHelper<XConnectionPoint>
 {
@@ -158,7 +161,7 @@ ScVbaApplication::RemoveSink( sal_uInt32 nNumber )
 
 ScVbaApplication::ScVbaApplication( const 
uno::Reference<uno::XComponentContext >& xContext ) :
     ScVbaApplication_BASE( xContext ),
-    mrAppSettings( ScVbaStaticAppSettings::get() ),
+    mrAppSettings( ScVbaStaticAppSettings() ),
     m_nDialogType(0)
 {
 }
@@ -169,7 +172,7 @@ ScVbaApplication::~ScVbaApplication()
 
 /*static*/ bool ScVbaApplication::getDocumentEventsEnabled()
 {
-    return ScVbaStaticAppSettings::get().mbEnableEvents;
+    return ScVbaStaticAppSettings().mbEnableEvents;
 }
 
 OUString SAL_CALL
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;
 }

Reply via email to