summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2018-12-19 17:47:57 +0100
committerMiklos Vajna <vmiklos@collabora.com>2018-12-19 21:55:10 +0100
commit2dc3a6c273cb82506842864481d78df7294debbf (patch)
tree08d5aa29956b92f06d47ded67eb981b9f50fcfcb /framework
parent95094b1b2bb6e99cc7fc6a017949699f3e6a761b (diff)
framework: allow loading a component on the main thread
The user-visible problem was that embedded (OLE) objects contained in a document that was loaded on a thread were not editable. This works in the loaded-with-UI case because the Windows version of the SalData constructor in vcl calls CoInitialize() (which sets the concurrency model of the main thread to STA) and then later the OleComponent constructor in embeddedobj calls OleInitialize(), which just realizes that the concurrency model is already set, and OLE editing works. However, if the document is loaded on a thread, things are different. The concurrency model of the thread is set to MTA in oslWorkerWrapperFunction() in sal, so the later OleInitialize() will fail with RPC_E_CHANGED_MODE, as it's not possible to set the concurrency model of a thread once it's set. Solve the problem by providing in opt-in way to execute the actual import on the main thread, since remote UNO clients always invoke Desktop::loadComponentFromURL() on a thread. Change-Id: I94f2721b599c3ae3e2ebc1c90dea649a69d51ef7 Reviewed-on: https://gerrit.libreoffice.org/65453 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'framework')
-rw-r--r--framework/source/services/frame.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/framework/source/services/frame.cxx b/framework/source/services/frame.cxx
index d9a58fe31ed1..b638a1130752 100644
--- a/framework/source/services/frame.cxx
+++ b/framework/source/services/frame.cxx
@@ -87,6 +87,7 @@
#include <tools/diagnose_ex.h>
#include <vcl/menu.hxx>
#include <unotools/cmdoptions.hxx>
+#include <vcl/threadex.hxx>
using namespace framework;
@@ -584,7 +585,17 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL XFrameImpl::loadComponentF
checkDisposed();
css::uno::Reference< css::frame::XComponentLoader > xThis(static_cast< css::frame::XComponentLoader* >(this), css::uno::UNO_QUERY);
- return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName, nSearchFlags, lArguments);
+
+ utl::MediaDescriptor aDescriptor(lArguments);
+ bool bOnMainThread = aDescriptor.getUnpackedValueOrDefault("OnMainThread", false);
+
+ if (bOnMainThread)
+ return vcl::solarthread::syncExecute(std::bind(&LoadEnv::loadComponentFromURL, xThis,
+ m_xContext, sURL, sTargetFrameName,
+ nSearchFlags, lArguments));
+ else
+ return LoadEnv::loadComponentFromURL(xThis, m_xContext, sURL, sTargetFrameName,
+ nSearchFlags, lArguments);
}
/*-****************************************************************************************************