From 2811d0a20e038f6fd573f31eff8d485bd16c81ce Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Mon, 8 Nov 2021 21:24:32 +0200 Subject: 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 --- desktop/source/app/appinit.cxx | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'desktop/source/app/appinit.cxx') 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 #include -#include #include #include #include @@ -122,8 +121,16 @@ typedef std::map< OUString, css::uno::Reference > 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 ); -- cgit