[Libreoffice-commits] core.git: shell/source
Julien Nabet (via logerrit)
logerrit at kemper.freedesktop.org
Sun Jun 7 07:41:03 UTC 2020
shell/source/win32/SysShExec.cxx | 11 ++++++++---
shell/source/win32/SysShExec.hxx | 3 +++
2 files changed, 11 insertions(+), 3 deletions(-)
New commits:
commit 6d2c6d827e827b62271c9636fe212045a4d68d42
Author: Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sat Jun 6 12:25:07 2020 +0200
Commit: Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Sun Jun 7 09:40:24 2020 +0200
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 at collabora.com>
Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>
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
More information about the Libreoffice-commits
mailing list