diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-10-02 14:18:49 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-10-02 20:40:53 +0200 |
commit | ad64650bda81ba59ebd27acaf67dc0b444ac0573 (patch) | |
tree | 6c8acc6eda7ef900c67e634ec89abfa3af37664f /stoc | |
parent | 7c70a59cd02a5b6111a9c39c74c8b6cd1585c4c2 (diff) |
Use the new single-instance="true" attribute in stoc
Change-Id: Icc0d2555bb90a5e0bf6ea828d14fb9e836dd7981
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103845
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/invocation_adapterfactory/iafactory.cxx | 8 | ||||
-rw-r--r-- | stoc/source/invocation_adapterfactory/invocadapt.component | 2 | ||||
-rw-r--r-- | stoc/source/proxy_factory/proxyfac.component | 2 | ||||
-rw-r--r-- | stoc/source/proxy_factory/proxyfac.cxx | 18 |
4 files changed, 6 insertions, 24 deletions
diff --git a/stoc/source/invocation_adapterfactory/iafactory.cxx b/stoc/source/invocation_adapterfactory/iafactory.cxx index 65322c3a6234..126af1f82851 100644 --- a/stoc/source/invocation_adapterfactory/iafactory.cxx +++ b/stoc/source/invocation_adapterfactory/iafactory.cxx @@ -23,7 +23,6 @@ #include <osl/mutex.hxx> #include <o3tl/sorted_vector.hxx> #include <sal/log.hxx> -#include <rtl/ref.hxx> #include <uno/dispatcher.h> #include <uno/data.h> @@ -33,7 +32,7 @@ #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> - +#include <cppuhelper/weak.hxx> #include <com/sun/star/script/XTypeConverter.hpp> #include <com/sun/star/script/XInvocationAdapterFactory.hpp> #include <com/sun/star/script/XInvocationAdapterFactory2.hpp> @@ -876,10 +875,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* stoc_invocation_adapter_get_implementation( css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&) { - static rtl::Reference<stoc_invadp::FactoryImpl> g_Instance(new stoc_invadp::FactoryImpl(context)); - - g_Instance->acquire(); - return static_cast<cppu::OWeakObject*>(g_Instance.get()); + return cppu::acquire(static_cast<cppu::OWeakObject*>(new stoc_invadp::FactoryImpl(context))); } diff --git a/stoc/source/invocation_adapterfactory/invocadapt.component b/stoc/source/invocation_adapterfactory/invocadapt.component index 9dbf20e48bad..ec1723e22a9b 100644 --- a/stoc/source/invocation_adapterfactory/invocadapt.component +++ b/stoc/source/invocation_adapterfactory/invocadapt.component @@ -20,7 +20,7 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="com.sun.star.comp.stoc.InvocationAdapterFactory" - constructor="stoc_invocation_adapter_get_implementation"> + constructor="stoc_invocation_adapter_get_implementation" single-instance="true"> <service name="com.sun.star.script.InvocationAdapterFactory"/> </implementation> </component> diff --git a/stoc/source/proxy_factory/proxyfac.component b/stoc/source/proxy_factory/proxyfac.component index eee87014ca98..b069f88dff81 100644 --- a/stoc/source/proxy_factory/proxyfac.component +++ b/stoc/source/proxy_factory/proxyfac.component @@ -20,7 +20,7 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="com.sun.star.comp.reflection.ProxyFactory" - constructor="stoc_FactoryImpl_get_implementation"> + constructor="stoc_FactoryImpl_get_implementation" single-instance="true"> <service name="com.sun.star.reflection.ProxyFactory"/> </implementation> </component> diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx index cecb6d917b39..b1c5597d0311 100644 --- a/stoc/source/proxy_factory/proxyfac.cxx +++ b/stoc/source/proxy_factory/proxyfac.cxx @@ -20,7 +20,6 @@ #include <osl/diagnose.h> #include <osl/interlck.h> -#include <osl/mutex.hxx> #include <rtl/ref.hxx> #include <uno/dispatcher.hxx> #include <uno/data.h> @@ -31,6 +30,7 @@ #include <cppuhelper/exc_hlp.hxx> #include <cppuhelper/implbase.hxx> #include <cppuhelper/supportsservice.hxx> +#include <cppuhelper/weak.hxx> #include <cppuhelper/weakagg.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/reflection/XProxyFactory.hpp> @@ -401,21 +401,7 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* stoc_FactoryImpl_get_implementation( css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&) { - Reference< XInterface > xRet; - static osl::Mutex s_mutex; - // note: don't use ::osl::Mutex::getGlobalMutex() here, it deadlocks - // with getImplHelperInitMutex() - ::osl::MutexGuard guard(s_mutex); - static WeakReference < XInterface > rwInstance; - xRet = rwInstance; - - if (! xRet.is()) - { - xRet = static_cast< ::cppu::OWeakObject * >(new FactoryImpl); - rwInstance = xRet; - } - xRet->acquire(); - return xRet.get(); + return cppu::acquire(static_cast< ::cppu::OWeakObject * >(new FactoryImpl)); } |