diff options
-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; |