[Libreoffice-commits] core.git: embeddedobj/source sfx2/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jul 14 09:52:34 UTC 2021
embeddedobj/source/msole/olecomponent.cxx | 8 +++++++-
sfx2/source/control/unoctitm.cxx | 21 ++++++++++++++++++++-
2 files changed, 27 insertions(+), 2 deletions(-)
New commits:
commit 19d473da14ac877cb0721063c7b18e16cb6f2b76
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jul 14 10:32:46 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Wed Jul 14 11:52:00 2021 +0200
sfx2: handle OnMainThread=true in SfxOfficeDispatch::dispatch()
This is needed when an out of process Java UNO client registers their
command dispatch interceptor, Windows OleInitialize() has been called
already on the main thread and then dispatching e.g. uno:Paste (which
would interact with OLE) would call OLE functions on a thread, which
would fail with RPC_E_CHANGED_MODE.
In other words, a situation similar to commit
22aa6508e0a65e65a6f9410b498fe4fd6c236639 (framework: allow dispatching a
command on the main thread, 2019-01-29), but that one was for
DispatchHelper, this one is for XDispatch implementations.
Change-Id: If5a80fe36962e014e781d2a8c156055f127e69a5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118886
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index cbcc1f6e79d7..b0c4fc62c1ac 100644
--- a/embeddedobj/source/msole/olecomponent.cxx
+++ b/embeddedobj/source/msole/olecomponent.cxx
@@ -35,6 +35,7 @@
#include <cppuhelper/interfacecontainer.h>
#include <comphelper/mimeconfighelper.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/windowserrorstring.hxx>
#include <osl/file.hxx>
#include <rtl/ref.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
@@ -445,9 +446,14 @@ OleComponent::OleComponent( const uno::Reference< uno::XComponentContext >& xCon
OSL_ENSURE( m_pUnoOleObject, "No owner object is provided!" );
HRESULT hr = OleInitialize( nullptr );
- OSL_ENSURE( hr == S_OK || hr == S_FALSE, "The ole can not be successfully initialized" );
if ( hr == S_OK || hr == S_FALSE )
m_bOleInitialized = true;
+ else
+ {
+ SAL_WARN("embeddedobj.ole", "OleComponent ctor: OleInitialize() failed with 0x"
+ << OUString::number(static_cast<sal_uInt32>(hr), 16) << ": "
+ << WindowsErrorStringFromHRESULT(hr));
+ }
m_pOleWrapClientSite = new OleWrapperClientSite( this );
m_pOleWrapClientSite->AddRef();
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 0a98f806d708..bc07f2af71d3 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -78,6 +78,8 @@
#include <comphelper/lok.hxx>
#include <desktop/crashreport.hxx>
+#include <vcl/threadex.hxx>
+#include <unotools/mediadescriptor.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -233,7 +235,24 @@ void SAL_CALL SfxOfficeDispatch::dispatch( const css::util::URL& aURL, const css
#if HAVE_FEATURE_JAVA
std::unique_ptr< css::uno::ContextLayer > layer(EnsureJavaContext());
#endif
- pImpl->dispatch( aURL, aArgs, css::uno::Reference < css::frame::XDispatchResultListener >() );
+ utl::MediaDescriptor aDescriptor(aArgs);
+ bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false);
+ if (bOnMainThread)
+ {
+ // Make sure that we own the solar mutex, otherwise later
+ // vcl::SolarThreadExecutor::execute() will release the solar mutex, even if it's owned by
+ // an other thread, leading to an std::abort() at the end.
+ SolarMutexGuard aGuard;
+ vcl::solarthread::syncExecute([this, &aURL, &aArgs]() {
+ pImpl->dispatch(aURL, aArgs,
+ css::uno::Reference<css::frame::XDispatchResultListener>());
+ });
+ }
+ else
+ {
+ pImpl->dispatch(aURL, aArgs,
+ css::uno::Reference<css::frame::XDispatchResultListener>());
+ }
}
}
More information about the Libreoffice-commits
mailing list