summaryrefslogtreecommitdiff
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
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
-rw-r--r--framework/source/dispatch/dispatchprovider.cxx9
-rw-r--r--include/framework/dispatchhelper.hxx10
-rw-r--r--sdext/source/presenter/PresenterProtocolHandler.hxx5
3 files changed, 23 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
{
diff --git a/include/framework/dispatchhelper.hxx b/include/framework/dispatchhelper.hxx
index 7c89a2d79aac..1595e2a3cea2 100644
--- a/include/framework/dispatchhelper.hxx
+++ b/include/framework/dispatchhelper.hxx
@@ -104,6 +104,16 @@ public:
// XEventListener
virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) override;
};
+
+/// Interface that allows a protocol handler implementation to opt out from framework caching.
+class SAL_NO_VTABLE SAL_DLLPUBLIC_RTTI CacheInfo
+{
+public:
+ virtual bool IsCachingAllowed() const = 0;
+
+protected:
+ ~CacheInfo() noexcept = default;
+};
}
#endif
diff --git a/sdext/source/presenter/PresenterProtocolHandler.hxx b/sdext/source/presenter/PresenterProtocolHandler.hxx
index 3a5e33f3b8a6..eaced08d9e6a 100644
--- a/sdext/source/presenter/PresenterProtocolHandler.hxx
+++ b/sdext/source/presenter/PresenterProtocolHandler.hxx
@@ -27,6 +27,7 @@
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <rtl/ref.hxx>
+#include <framework/dispatchhelper.hxx>
namespace sdext::presenter {
@@ -40,6 +41,7 @@ class PresenterController;
class PresenterProtocolHandler
: protected ::cppu::BaseMutex,
+ public framework::CacheInfo,
public PresenterProtocolHandlerInterfaceBase
{
public:
@@ -71,6 +73,9 @@ public:
queryDispatches(
const css::uno::Sequence< css::frame::DispatchDescriptor>& rDescriptors) override;
+ /// See framework::CacheInfo::IsCachingAllowed().
+ bool IsCachingAllowed() const override { return false; }
+
private:
class Dispatch;
::rtl::Reference<PresenterController> mpPresenterController;