[Libreoffice-commits] core.git: scripting/source sfx2/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Oct 8 17:51:46 UTC 2018
scripting/source/basprov/basprov.cxx | 22 ++++++---------------
scripting/source/dlgprov/dlgprov.cxx | 14 ++-----------
scripting/source/stringresource/stringresource.cxx | 14 ++-----------
sfx2/source/doc/objxtor.cxx | 14 +------------
4 files changed, 15 insertions(+), 49 deletions(-)
New commits:
commit 9ed8a1bfffd608b31badeae5341ebf0b48501419
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
AuthorDate: Mon Oct 8 16:32:04 2018 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Oct 8 19:51:24 2018 +0200
replace double-checked locking patterns with thread safe ...
local statics.
Change-Id: Iab4963a04d15f06e9b1a36079a36d32453e09c8f
Reviewed-on: https://gerrit.libreoffice.org/61538
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx
index 6180fa333627..ce71c003d75d 100644
--- a/scripting/source/basprov/basprov.cxx
+++ b/scripting/source/basprov/basprov.cxx
@@ -76,21 +76,13 @@ namespace basprov
static Sequence< OUString > getSupportedServiceNames_BasicProviderImpl()
{
- static Sequence< OUString >* pNames = nullptr;
- if ( !pNames )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if ( !pNames )
- {
- static Sequence< OUString > aNames(4);
- aNames.getArray()[0] = "com.sun.star.script.provider.ScriptProviderForBasic";
- aNames.getArray()[1] = "com.sun.star.script.provider.LanguageScriptProvider";
- aNames.getArray()[2] = "com.sun.star.script.provider.ScriptProvider";
- aNames.getArray()[3] = "com.sun.star.script.browse.BrowseNode";
- pNames = &aNames;
- }
- }
- return *pNames;
+ static Sequence< OUString > s_Names{
+ "com.sun.star.script.provider.ScriptProviderForBasic",
+ "com.sun.star.script.provider.LanguageScriptProvider",
+ "com.sun.star.script.provider.ScriptProvider",
+ "com.sun.star.script.browse.BrowseNode"};
+
+ return s_Names;
}
diff --git a/scripting/source/dlgprov/dlgprov.cxx b/scripting/source/dlgprov/dlgprov.cxx
index 90a28cca56fd..4f979ee54308 100644
--- a/scripting/source/dlgprov/dlgprov.cxx
+++ b/scripting/source/dlgprov/dlgprov.cxx
@@ -177,17 +177,9 @@ namespace dlgprov
::osl::Mutex& getMutex()
{
- static ::osl::Mutex* s_pMutex = nullptr;
- if ( !s_pMutex )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if ( !s_pMutex )
- {
- static ::osl::Mutex s_aMutex;
- s_pMutex = &s_aMutex;
- }
- }
- return *s_pMutex;
+ static ::osl::Mutex s_aMutex;
+
+ return s_aMutex;
}
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index a17977536056..9e29229e13e0 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -62,17 +62,9 @@ namespace stringresource
::osl::Mutex& getMutex()
{
- static ::osl::Mutex* s_pMutex = nullptr;
- if ( !s_pMutex )
- {
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if ( !s_pMutex )
- {
- static ::osl::Mutex s_aMutex;
- s_pMutex = &s_aMutex;
- }
- }
- return *s_pMutex;
+ static ::osl::Mutex s_aMutex;
+
+ return s_aMutex;
}
diff --git a/sfx2/source/doc/objxtor.cxx b/sfx2/source/doc/objxtor.cxx
index 8eef03e8d5cc..a03e3b7ddd95 100644
--- a/sfx2/source/doc/objxtor.cxx
+++ b/sfx2/source/doc/objxtor.cxx
@@ -838,19 +838,9 @@ SfxObjectShell* SfxObjectShell::GetObjectShell()
uno::Sequence< OUString > SfxObjectShell::GetEventNames()
{
- static uno::Sequence< OUString >* pEventNameContainer = nullptr;
+ static uno::Sequence< OUString > s_EventNameContainer(rtl::Reference<GlobalEventConfig>(new GlobalEventConfig)->getElementNames());
- if ( !pEventNameContainer )
- {
- SolarMutexGuard aGuard;
- if ( !pEventNameContainer )
- {
- static uno::Sequence< OUString > aEventNameContainer = rtl::Reference<GlobalEventConfig>(new GlobalEventConfig)->getElementNames();
- pEventNameContainer = &aEventNameContainer;
- }
- }
-
- return *pEventNameContainer;
+ return s_EventNameContainer;
}
More information about the Libreoffice-commits
mailing list