diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2020-06-06 12:25:07 +0200 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2020-06-07 09:40:24 +0200 |
commit | 6d2c6d827e827b62271c9636fe212045a4d68d42 (patch) | |
tree | b8f629dc7eb0a88eb54d3bf77f155431c4bcdad9 /shell | |
parent | 4c38441c3ae5f13aa61bb429b82f080afd9ed205 (diff) |
Use o3tl::safeCoInitializeEx/safeCoUninitializeReinit (shell/SysShExec)
Change-Id: Ice97c2db27085fefed098ee01f3aaeb55fc90cca
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95643
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/source/win32/SysShExec.cxx | 11 | ||||
-rw-r--r-- | shell/source/win32/SysShExec.hxx | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/shell/source/win32/SysShExec.cxx b/shell/source/win32/SysShExec.cxx index 93eeaee36f03..a68315e8d3e6 100644 --- a/shell/source/win32/SysShExec.cxx +++ b/shell/source/win32/SysShExec.cxx @@ -33,6 +33,7 @@ #include <cppuhelper/supportsservice.hxx> #include <o3tl/char16_t2wchar_t.hxx> #include <o3tl/runtimetooustring.hxx> +#include <o3tl/safeCoInitUninit.hxx> #include <prewin.h> #include <Shlobj.h> @@ -146,7 +147,8 @@ namespace CSysShExec::CSysShExec( const css::uno::Reference< css::uno::XComponentContext >& xContext ) : WeakComponentImplHelper< css::system::XSystemShellExecute, css::lang::XServiceInfo >( m_aMutex ), - m_xContext(xContext) + m_xContext(xContext), + mnNbCallCoInitializeExForReinit(0) { /* * As this service is declared thread-affine, it is ensured to be called from a @@ -155,8 +157,11 @@ CSysShExec::CSysShExec( const css::uno::Reference< css::uno::XComponentContext > * We need COM to be initialized for STA, but osl thread get initialized for MTA. * Once this changed, we can remove the uninitialize call. */ - CoUninitialize(); - CoInitializeEx( nullptr, COINIT_APARTMENTTHREADED ); + o3tl::safeCoInitializeEx(COINIT_APARTMENTTHREADED, mnNbCallCoInitializeExForReinit); +} +CSysShExec::~CSysShExec() +{ + o3tl::safeCoUninitializeReinit(COINIT_MULTITHREADED, mnNbCallCoInitializeExForReinit); } namespace diff --git a/shell/source/win32/SysShExec.hxx b/shell/source/win32/SysShExec.hxx index 63069cc5e52f..8a4e65ffa5e9 100644 --- a/shell/source/win32/SysShExec.hxx +++ b/shell/source/win32/SysShExec.hxx @@ -43,9 +43,12 @@ class CSysShExec : css::lang::XServiceInfo > { css::uno::Reference< css::uno::XComponentContext > m_xContext; + // to put back all the inits with COINIT_MULTITHREADED if needed + int mnNbCallCoInitializeExForReinit; public: explicit CSysShExec(const css::uno::Reference< css::uno::XComponentContext >& xContext); + ~CSysShExec(); // XSystemShellExecute |