summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-04-28 14:43:09 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-04-29 09:37:39 +0200
commit6544a10541fce546034a5411cd6333c2d94fe965 (patch)
tree3b038bd2b7f684242ec8aef51c203d48e71b2665
parentd377f4d9c0449a4acece1bddedb3c081f5e1d0ed (diff)
framework: allow loading a component on the main thread, using XDesktop
This is similar to commit 2dc3a6c273cb82506842864481d78df7294debbf (framework: allow loading a component on the main thread, 2018-12-19), but that focused on the special case when loading happens via XFrame. The more frequently used XDesktop way now supports the same flag, allowing correctly loading "real" OLE objects on Windows. (cherry picked from commit 6002014ce0a5c9cea22c14b2437b7a508b2c72cb) Change-Id: I059ea143c91894508d8264084094eefc2bff24e8
-rw-r--r--framework/source/services/desktop.cxx21
1 files changed, 20 insertions, 1 deletions
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 998f0af29a62..91611d4eaa45 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -57,6 +57,7 @@
#include <vcl/scheduler.hxx>
#include <sal/log.hxx>
#include <vcl/errcode.hxx>
+#include <vcl/threadex.hxx>
#include <unotools/configmgr.hxx>
namespace framework{
@@ -623,7 +624,25 @@ css::uno::Reference< css::lang::XComponent > SAL_CALL Desktop::loadComponentFrom
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)
+ {
+ // Make sure that we own the solar mutex, otherwise later
+ // vcl::SolarThreadExecutor::execute() will release the solar mutex, even if it's owned by
+ // another thread, leading to an std::abort() at the end.
+ SolarMutexGuard g;
+
+ 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);
+ }
}
/*-************************************************************************************************************