From 0f506617258341596747416549c8f0f879267ab0 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 17 Dec 2019 09:11:03 +0100 Subject: 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 --- framework/source/services/desktop.cxx | 42 +++++++---------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) (limited to 'framework/source/services/desktop.cxx') 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 const & context): - instance(new framework::Desktop(context)) - { - instance->constructorInit(); - } - - rtl::Reference instance; -}; - -struct InstanceInit { - Instance * operator() (css::uno::Reference const& xContext) { - static Instance instance(xContext); - return &instance; - } -}; - -struct GetSolarMutex { - comphelper::SolarMutex * operator() () - { - return &Application::GetSolarMutex(); - } -}; - -Instance & getInstance(css::uno::Reference const& xContext) +rtl::Reference createDesktop( + css::uno::Reference const & context) { - // tdf#114025 init with SolarMutex to avoid deadlock - return *rtl_Instance, - GetSolarMutex, - css::uno::Reference const> - ::create(InstanceInit(), GetSolarMutex(), xContext); + SolarMutexGuard g; // tdf#114025 init with SolarMutex to avoid deadlock + rtl::Reference 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 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: */ -- cgit