summaryrefslogtreecommitdiffstats
path: root/desktop
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-11-08 21:24:32 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-12 10:16:14 +0100
commit2811d0a20e038f6fd573f31eff8d485bd16c81ce (patch)
tree253e23996690c4f14e8715a6ecaf210fc9a5a3a7 /desktop
parentUse more o3tl::convert in sc (diff)
downloadcore-2811d0a20e038f6fd573f31eff8d485bd16c81ce.tar.gz
core-2811d0a20e038f6fd573f31eff8d485bd16c81ce.zip
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')
-rw-r--r--desktop/inc/dp_shared.hxx18
-rw-r--r--desktop/source/app/appinit.cxx25
-rw-r--r--desktop/source/app/officeipcthread.cxx1
-rw-r--r--desktop/source/deployment/misc/dp_misc.cxx8
4 files changed, 26 insertions, 26 deletions
diff --git a/desktop/inc/dp_shared.hxx b/desktop/inc/dp_shared.hxx
index 0ce0bc401d65..dbd695c31b9b 100644
--- a/desktop/inc/dp_shared.hxx
+++ b/desktop/inc/dp_shared.hxx
@@ -19,23 +19,9 @@
#pragma once
-#include <rtl/instance.hxx>
#include <unotools/resmgr.hxx>
+#include <dp_misc_api.hxx>
-namespace dp {
-
-struct DeploymentLocale :
- public ::rtl::StaticWithInit<std::locale, DeploymentLocale > {
- std::locale operator () () {
- return Translate::Create("dkt");
- }
-};
-
-} // namespace dp
-
-inline OUString DpResId(TranslateId aId)
-{
- return Translate::get(aId, dp::DeploymentLocale::get());
-}
+DESKTOP_DEPLOYMENTMISC_DLLPUBLIC OUString DpResId(TranslateId aId);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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 );
diff --git a/desktop/source/app/officeipcthread.cxx b/desktop/source/app/officeipcthread.cxx
index 61827856f3e9..07880d27fc4c 100644
--- a/desktop/source/app/officeipcthread.cxx
+++ b/desktop/source/app/officeipcthread.cxx
@@ -36,7 +36,6 @@
#include <osl/pipe.hxx>
#include <rtl/digest.h>
#include <rtl/ustrbuf.hxx>
-#include <rtl/instance.hxx>
#include <osl/conditn.hxx>
#include <unotools/moduleoptions.hxx>
#include <rtl/strbuf.hxx>
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx
index 63f684666857..f4437711dab5 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -23,6 +23,7 @@
#include <dp_misc.h>
#include <dp_interact.h>
+#include <dp_shared.hxx>
#include <rtl/uri.hxx>
#include <rtl/digest.h>
#include <rtl/random.h>
@@ -550,4 +551,11 @@ void disposeBridges(Reference<css::uno::XComponentContext> const & ctx)
}
+OUString DpResId(TranslateId aId)
+{
+ static std::locale SINGLETON = Translate::Create("dkt");
+ return Translate::get(aId, SINGLETON);
+}
+
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */