summaryrefslogtreecommitdiff
path: root/framework/source/dispatch
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2022-05-26 13:57:12 +0200
committerMiklos Vajna <vmiklos@collabora.com>2022-05-26 15:09:30 +0200
commitc0fa456436947a5c167c652d19a884064b43c03d (patch)
tree1974427a37c29564d11b3cc3b7f3cad43690c821 /framework/source/dispatch
parentfc45e54be6ba5d4685ae4ef3c3ea696fc99cccd4 (diff)
tdf#149261 sdext: fix crash on starting the presenter console for the 2nd time
This started with commit 3f768cddd28a2f04eb1ffa30bed4474deb6fbfc4 (framework: avoid re-creating protocol handler instances all the time, 2022-05-02). In case there are 2 monitors, then one monitor shows the slideshow, the other shows the presenter console. The presenter console's protocol handler in sdext::presenter::PresenterProtocolHandler::Dispatch::Dispatch() has mpPresenterController->GetWindowManager() as an empty reference on the 2nd time the presentation starts. The above commit started to cache protocol handler instances at a frame level for performance reasons, and this is meant to be safe in general, but the presenter console's window manager is re-created between slideshow runs, so it depends on framework/ code to re-create the protocol handler all the time, which is problematic here. Fix the problem by introducing a framework::CacheInfo interface that allows protocol handler implementations to signal if they want to avoid being cached. This should be good enough for now, but if later it turns out that there are too many broken protocol handlers out there, then we can consider flipping the default and only cache handlers which explicitly opt in for this behavior. This is not done in this commit. Change-Id: Ic159813b1b339540bc8c4e780c4d6d7d2d4d2445 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135020 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'framework/source/dispatch')
-rw-r--r--framework/source/dispatch/dispatchprovider.cxx9
1 files changed, 8 insertions, 1 deletions
diff --git a/framework/source/dispatch/dispatchprovider.cxx b/framework/source/dispatch/dispatchprovider.cxx
index bcfa07bb333a..c16a0085a0a5 100644
--- a/framework/source/dispatch/dispatchprovider.cxx
+++ b/framework/source/dispatch/dispatchprovider.cxx
@@ -36,6 +36,7 @@
#include <rtl/ustring.hxx>
#include <vcl/svapp.hxx>
#include <sal/log.hxx>
+#include <framework/dispatchhelper.hxx>
namespace framework{
@@ -451,7 +452,13 @@ css::uno::Reference< css::frame::XDispatch > DispatchProvider::implts_searchProt
css::uno::Reference<css::lang::XMultiServiceFactory>(m_xContext->getServiceManager(), css::uno::UNO_QUERY_THROW)
->createInstance(aHandler.m_sUNOName),
css::uno::UNO_QUERY);
- m_aProtocolHandlers.emplace(aHandler.m_sUNOName, xHandler);
+
+ // Check if the handler explicitly requested to avoid caching.
+ auto pCacheInfo = dynamic_cast<framework::CacheInfo*>(xHandler.get());
+ if (!pCacheInfo || pCacheInfo->IsCachingAllowed())
+ {
+ m_aProtocolHandlers.emplace(aHandler.m_sUNOName, xHandler);
+ }
}
else
{