diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-11-08 21:24:32 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-11-12 10:16:14 +0100 |
commit | 2811d0a20e038f6fd573f31eff8d485bd16c81ce (patch) | |
tree | 253e23996690c4f14e8715a6ecaf210fc9a5a3a7 /desktop/source/app/appinit.cxx | |
parent | 00d74a5e0291a40e532b2a0f51fdd5a3e1f487ed (diff) |
rtl::Static to thread-safe static
Change-Id: I6390d1811bad59c09a074039c635710d25a660d7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124886
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'desktop/source/app/appinit.cxx')
-rw-r--r-- | desktop/source/app/appinit.cxx | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/desktop/source/app/appinit.cxx b/desktop/source/app/appinit.cxx index bc4af1c681b8..98a1fa61ca2f 100644 --- a/desktop/source/app/appinit.cxx +++ b/desktop/source/app/appinit.cxx @@ -36,7 +36,6 @@ #include <sal/log.hxx> #include <tools/diagnose_ex.h> -#include <rtl/instance.hxx> #include <comphelper/processfactory.hxx> #include <unotools/ucbhelper.hxx> #include <unotools/tempfile.hxx> @@ -122,8 +121,16 @@ typedef std::map< OUString, css::uno::Reference<css::lang::XInitialization> > Ac namespace { - struct acceptorMap : public rtl::Static< AcceptorMap, acceptorMap > {}; - struct CurrentTempURL : public rtl::Static< OUString, CurrentTempURL > {}; + AcceptorMap& acceptorMap() + { + static AcceptorMap SINGLETON; + return SINGLETON; + } + OUString& CurrentTempURL() + { + static OUString SINGLETON; + return SINGLETON; + } } static bool bAccept = false; @@ -131,7 +138,7 @@ static bool bAccept = false; void Desktop::createAcceptor(const OUString& aAcceptString) { // check whether the requested acceptor already exists - AcceptorMap &rMap = acceptorMap::get(); + AcceptorMap &rMap = acceptorMap(); AcceptorMap::const_iterator pIter = rMap.find(aAcceptString); if (pIter != rMap.end() ) return; @@ -188,7 +195,7 @@ IMPL_STATIC_LINK_NOARG(Desktop, EnableAcceptors_Impl, void*, void) bAccept = true; // enable existing acceptors by calling initialize(true) // on all existing acceptors - AcceptorMap &rMap = acceptorMap::get(); + AcceptorMap &rMap = acceptorMap(); std::for_each(rMap.begin(), rMap.end(), enable()); } } @@ -196,7 +203,7 @@ IMPL_STATIC_LINK_NOARG(Desktop, EnableAcceptors_Impl, void*, void) void Desktop::destroyAcceptor(const OUString& aAcceptString) { // special case stop all acceptors - AcceptorMap &rMap = acceptorMap::get(); + AcceptorMap &rMap = acceptorMap(); if (aAcceptString == "all") { rMap.clear(); @@ -217,7 +224,7 @@ void Desktop::destroyAcceptor(const OUString& aAcceptString) void Desktop::DeregisterServices() { // stop all acceptors by clearing the map - acceptorMap::get().clear(); + acceptorMap().clear(); } void Desktop::CreateTemporaryDirectory() @@ -252,13 +259,13 @@ void Desktop::CreateTemporaryDirectory() { aRet.clear(); } - CurrentTempURL::get() = aRet; + CurrentTempURL() = aRet; } void Desktop::RemoveTemporaryDirectory() { // remove current temporary directory - OUString &rCurrentTempURL = CurrentTempURL::get(); + OUString &rCurrentTempURL = CurrentTempURL(); if ( !rCurrentTempURL.isEmpty() ) { ::utl::UCBContentHelper::Kill( rCurrentTempURL ); |