summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2019-12-17 09:11:03 +0100
committerStephan Bergmann <sbergman@redhat.com>2019-12-17 10:06:30 +0100
commit0f506617258341596747416549c8f0f879267ab0 (patch)
treed4192757f098f3cac8e8ce755f47f6e3308e26c1
parentced9702c9fcba0c702f0b910c3f1f5dae69a4f5a (diff)
Elide use of rtl_Instance (which is obsoleted by C++11 thread-safe statics)
Change-Id: I9ee0d2ecbb75afe5a341eac308bb6718e5830749 Reviewed-on: https://gerrit.libreoffice.org/85262 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--framework/source/services/desktop.cxx42
1 files changed, 8 insertions, 34 deletions
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 03e6bf2750f1..94f41f9fa1af 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -1771,40 +1771,13 @@ bool Desktop::impl_closeFrames(bool bAllowUI)
namespace {
-struct Instance {
- explicit Instance(
- css::uno::Reference<css::uno::XComponentContext> const & context):
- instance(new framework::Desktop(context))
- {
- instance->constructorInit();
- }
-
- rtl::Reference<framework::Desktop> instance;
-};
-
-struct InstanceInit {
- Instance * operator() (css::uno::Reference<css::uno::XComponentContext> const& xContext) {
- static Instance instance(xContext);
- return &instance;
- }
-};
-
-struct GetSolarMutex {
- comphelper::SolarMutex * operator() ()
- {
- return &Application::GetSolarMutex();
- }
-};
-
-Instance & getInstance(css::uno::Reference<css::uno::XComponentContext> const& xContext)
+rtl::Reference<framework::Desktop> createDesktop(
+ css::uno::Reference<css::uno::XComponentContext> const & context)
{
- // tdf#114025 init with SolarMutex to avoid deadlock
- return *rtl_Instance<Instance,
- InstanceInit,
- osl::Guard<comphelper::SolarMutex>,
- GetSolarMutex,
- css::uno::Reference<css::uno::XComponentContext> const>
- ::create(InstanceInit(), GetSolarMutex(), xContext);
+ SolarMutexGuard g; // tdf#114025 init with SolarMutex to avoid deadlock
+ rtl::Reference<framework::Desktop> desktop(new framework::Desktop(context));
+ desktop->constructorInit();
+ return desktop;
}
}
@@ -1814,7 +1787,8 @@ com_sun_star_comp_framework_Desktop_get_implementation(
css::uno::XComponentContext *context,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(getInstance(context).instance.get());
+ static auto const instance = createDesktop(context);
+ return cppu::acquire(instance.get());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */