[Libreoffice-commits] core.git: Branch 'distro/lhm/libreoffice-6-4+backports' - framework/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Wed Jun 16 06:38:10 UTC 2021


 framework/source/services/desktop.cxx |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

New commits:
commit a129def3932c8d0593c050268a839fc6a3ef8a2b
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Apr 28 14:43:09 2021 +0200
Commit:     Michael Weghorn <m.weghorn at posteo.de>
CommitDate: Wed Jun 16 08:37:38 2021 +0200

    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.
    
    Change-Id: I059ea143c91894508d8264084094eefc2bff24e8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114805
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 6002014ce0a5c9cea22c14b2437b7a508b2c72cb)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117281
    Tested-by: Michael Weghorn <m.weghorn at posteo.de>
    Reviewed-by: Michael Weghorn <m.weghorn at posteo.de>

diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index cce5892f0646..5240e565554c 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -72,6 +72,7 @@
 #include <rtl/ustrbuf.hxx>
 
 #include <vcl/errinf.hxx>
+#include <vcl/threadex.hxx>
 #include <unotools/configmgr.hxx>
 
 namespace framework{
@@ -619,7 +620,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);
+    }
 }
 
 /*-************************************************************************************************************


More information about the Libreoffice-commits mailing list