diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2022-05-30 11:08:12 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2022-05-30 12:08:03 +0200 |
commit | b3f2ae52e381f7d5fa466dc9df7d04d3d13ca4b9 (patch) | |
tree | c0e45d2081ffc31c709c104f3784e2c86141cf7b /framework | |
parent | e4e03e79fac598a9fafb0da8ab50da9a67c6978e (diff) |
framework: fix crash on Writer startup when using --enable-ext-wiki-publisher
As reported by Julien, once the mediawiki extension is installed, the
xHandler in framework::DispatchProvider::implts_searchProtocolHandler()
points to an UNO component implemented in Java, and we crash in
dynamic_cast<>(), at least on Linux with gcc 7.5 and libstdc++.
This dynamic_cast<>() call was added in commit
c0fa456436947a5c167c652d19a884064b43c03d (tdf#149261 sdext: fix crash on
starting the presenter console for the 2nd time, 2022-05-26), to allow
the presenter console to opt out from protocol handler caching. It was
expected that the proxy object created for a Java UNO component would
simply return nullptr when we try to dynamic_cast<>() it down to a C++
interface.
Fix the problem by moving the interface to an UNO one: this side-steps
the dynamic_cast<>() crash at the price of introducing an UNO interface,
which is not meant to be part of the public UNO API (but at least it's
not published).
It may still make sense to improve the bridges/ code at some stage to
not crash in dynamic_cast<>() on generated Java proxy objects.
Change-Id: Iaac44515339e0dc15dddc3be45ef7dee7331e47a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135114
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/source/dispatch/dispatchprovider.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx index c16a0085a0a5..1c214ddaa48f 100644 --- a/framework/source/dispatch/dispatchprovider.cxx +++ b/framework/source/dispatch/dispatchprovider.cxx @@ -32,6 +32,7 @@ #include <com/sun/star/uno/Exception.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/util/XCacheInfo.hpp> #include <rtl/ustring.hxx> #include <vcl/svapp.hxx> @@ -454,8 +455,8 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt css::uno::UNO_QUERY); // Check if the handler explicitly requested to avoid caching. - auto pCacheInfo = dynamic_cast<framework::CacheInfo*>(xHandler.get()); - if (!pCacheInfo || pCacheInfo->IsCachingAllowed()) + css::uno::Reference<css::util::XCacheInfo> xCacheInfo(xHandler, css::uno::UNO_QUERY); + if (!xCacheInfo.is() || xCacheInfo->isCachingAllowed()) { m_aProtocolHandlers.emplace(aHandler.m_sUNOName, xHandler); } |