[Libreoffice-commits] core.git: Branch 'distro/vector/vector-7.0' - 3 commits - embeddedobj/source framework/source sfx2/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Thu Jul 15 09:05:47 UTC 2021
embeddedobj/source/msole/olecomponent.cxx | 8 ++++++-
framework/source/dispatch/interceptionhelper.cxx | 17 ++++++++++++++-
sfx2/source/control/statcach.cxx | 10 +++++++-
sfx2/source/control/unoctitm.cxx | 26 ++++++++++++++++++++++-
4 files changed, 57 insertions(+), 4 deletions(-)
New commits:
commit d5b606b2d1d6b56e319c424c7367846c14760926
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Wed Jul 14 10:32:46 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 15 11:04:26 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.
(cherry picked from commit 19d473da14ac877cb0721063c7b18e16cb6f2b76)
Conflicts:
sfx2/source/control/unoctitm.cxx
Change-Id: If5a80fe36962e014e781d2a8c156055f127e69a5
diff --git a/embeddedobj/source/msole/olecomponent.cxx b/embeddedobj/source/msole/olecomponent.cxx
index 514a24d86f06..84e3c6a58c5f 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< lang::XMultiServiceFactory >&
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 5d2b5c2dfa01..8352ee616692 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -75,6 +75,8 @@
#include <sal/log.hxx>
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <comphelper/lok.hxx>
+#include <vcl/threadex.hxx>
+#include <unotools/mediadescriptor.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -230,7 +232,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>());
+ }
}
}
commit 9e50a33238d4bc537adde7ae6da3c832e0f435ed
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jul 13 13:57:30 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 15 11:02:59 2021 +0200
framework, sfx2: catch more exceptions when the object is already disposed
This can happen when an out of process Java object is registered as a
callback, then that Java process exits without notifying us.
Handle this failure by just ignoring that object, so we don't crash on
soffice process shutdown.
(cherry picked from commit 58aac6e941c0a84e568c14e2aa276c867f725dff)
Change-Id: I5d61e76494c62148ef0c3db24789a5ea6e5843eb
diff --git a/framework/source/dispatch/interceptionhelper.cxx b/framework/source/dispatch/interceptionhelper.cxx
index 899ce2440946..5287244b677a 100644
--- a/framework/source/dispatch/interceptionhelper.cxx
+++ b/framework/source/dispatch/interceptionhelper.cxx
@@ -20,8 +20,12 @@
#include <dispatch/interceptionhelper.hxx>
#include <com/sun/star/frame/XInterceptorInfo.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
#include <osl/diagnose.h>
#include <vcl/svapp.hxx>
+#include <tools/diagnose_ex.h>
+
+using namespace com::sun::star;
namespace framework{
@@ -185,7 +189,18 @@ void SAL_CALL InterceptionHelper::releaseDispatchProviderInterceptor(const css::
xMasterI->setSlaveDispatchProvider(xSlaveD);
if (xSlaveI.is())
- xSlaveI->setMasterDispatchProvider(xMasterD);
+ {
+ try
+ {
+ xSlaveI->setMasterDispatchProvider(xMasterD);
+ }
+ catch (const lang::DisposedException&)
+ {
+ TOOLS_WARN_EXCEPTION("fwk.dispatch",
+ "InterceptionHelper::releaseDispatchProviderInterceptor: "
+ "xSlaveI is disposed: ");
+ }
+ }
xInterceptor->setSlaveDispatchProvider (css::uno::Reference< css::frame::XDispatchProvider >());
xInterceptor->setMasterDispatchProvider(css::uno::Reference< css::frame::XDispatchProvider >());
diff --git a/sfx2/source/control/statcach.cxx b/sfx2/source/control/statcach.cxx
index dfdc10f83687..6f349c82c594 100644
--- a/sfx2/source/control/statcach.cxx
+++ b/sfx2/source/control/statcach.cxx
@@ -41,6 +41,7 @@
#include <unoctitm.hxx>
#include <sfx2/msgpool.hxx>
#include <sfx2/viewfrm.hxx>
+#include <tools/diagnose_ex.h>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -144,7 +145,14 @@ void BindDispatch_Impl::Release()
{
if ( xDisp.is() )
{
- xDisp->removeStatusListener( static_cast<css::frame::XStatusListener*>(this), aURL );
+ try
+ {
+ xDisp->removeStatusListener(static_cast<css::frame::XStatusListener*>(this), aURL);
+ }
+ catch (const lang::DisposedException&)
+ {
+ TOOLS_WARN_EXCEPTION("sfx", "BindDispatch_Impl::Release: xDisp is disposed: ");
+ }
xDisp.clear();
}
pCache = nullptr;
commit 9024b7fc4752a5422d9b944c5ed81af138b7c0f5
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Jul 12 16:47:51 2021 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Jul 15 11:02:44 2021 +0200
sfx2: fix assert failure when deleting SfxOfficeDispatch on a thread
Steps to reproduce the problem:
1) Start soffice with "--accept=socket,host=localhost,port=9999;urp;StarOffice.ServiceManager"
2) Run a java / uno example that registers a custom dispatch interceptor
by calling registerDispatchProviderInterceptor().
3) Open a Writer document, choose insert -> object -> ole object ->
spreadsheet (i.e. Calc)
Then this assertion failure is hit:
tllo.dll!DbgTestSolarMutex() Line 96
at C:\lo\master\tools\source\debug\debug.cxx(96)
svllo.dll!SfxBroadcaster::RemoveListener(SfxListener & rListener) Line 104
at C:\lo\master\svl\source\notify\SfxBroadcaster.cxx(104)
svllo.dll!SfxListener::~SfxListener() Line 54
at C:\lo\master\svl\source\notify\lstner.cxx(54)
sfxlo.dll!SfxDispatchController_Impl::~SfxDispatchController_Impl() Line 367
at C:\lo\master\sfx2\source\control\unoctitm.cxx(367)
sfxlo.dll!SfxOfficeDispatch::~SfxOfficeDispatch() Line 192
at C:\lo\master\sfx2\source\control\unoctitm.cxx(192)
Given that SfxListener wants its caller to lock the solar mutex and
SfxDispatchController_Impl inherits from SfxListener, lock the mutex in
the SfxOfficeDispatch dtor and explicitly delete
SfxDispatchController_Impl while the mutex is still locked.
(cherry picked from commit a023a967978a334fd5016ab325864796def295cc)
Change-Id: Ib4201ef7866aaadedf9dfa8bd581ebe7a3bcf29a
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 00b9c7188d67..5d2b5c2dfa01 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -182,6 +182,11 @@ SfxOfficeDispatch::~SfxOfficeDispatch()
{
// when dispatch object is released, destroy its connection to this object and destroy it
pImpl->UnBindController();
+
+ // Ensure that SfxDispatchController_Impl is deleted while the solar mutex is locked, since
+ // that derives from SfxListener.
+ SolarMutexGuard aGuard;
+ pImpl.reset();
}
}
More information about the Libreoffice-commits
mailing list