diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-10-02 14:21:27 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-10-02 21:12:20 +0200 |
commit | d94aa8bd603bec2027f6eed6ac63d8c1cc40e054 (patch) | |
tree | 61d3a2f6de5c7a6fb2e5f7c693f10cbe8df1f187 | |
parent | c1152bceb7593e47fcf6dc51d9538adfb5bd3c6e (diff) |
Use the new single-instance="true" attribute in pyuno
Change-Id: I953dcc31445fc76d219903da56b2cc264f28c220
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103848
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r-- | pyuno/source/loader/pythonloader.component | 2 | ||||
-rw-r--r-- | pyuno/source/loader/pyuno_loader.cxx | 9 |
2 files changed, 4 insertions, 7 deletions
diff --git a/pyuno/source/loader/pythonloader.component b/pyuno/source/loader/pythonloader.component index 4e22781a6e60..4fc4a255ca2e 100644 --- a/pyuno/source/loader/pythonloader.component +++ b/pyuno/source/loader/pythonloader.component @@ -20,7 +20,7 @@ <component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" xmlns="http://openoffice.org/2010/uno-components"> <implementation name="org.openoffice.comp.pyuno.Loader" - constructor="pyuno_Loader_get_implementation"> + constructor="pyuno_Loader_get_implementation" single-instance="true"> <service name="com.sun.star.loader.Python"/> </implementation> </component> diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index db6acb04dbd8..a92a538161b1 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -172,9 +172,7 @@ static void prependPythonPath( const OUString & pythonPathBootstrap ) namespace { -struct PythonInit -{ -PythonInit() { +void pythonInit() { if ( Py_IsInitialized()) // may be inited by getComponentContext() already return; @@ -228,7 +226,6 @@ PythonInit() { // PyThreadAttach below. PyThreadState_Delete(tstate); } -}; } @@ -236,8 +233,8 @@ extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface* pyuno_Loader_get_implementation( css::uno::XComponentContext* ctx , css::uno::Sequence<css::uno::Any> const&) { - // tdf#114815 thread-safe static to init python only once - static PythonInit s_Init; + // tdf#114815 init python only once, via single-instace="true" in pythonloader.component + pythonInit(); Reference< XInterface > ret; |