From ba796f2cddb8e63e1ec99e5c32b71d86fdf8e7d6 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 3 Nov 2018 16:48:49 +0300 Subject: tdf#121143: don't send OnCloseApp twice; properly cleanup AppBasicManager The OnCloseApp event is being sent twice: first time in SfxTerminateListener_Impl::notifyTermination (in Desktop::terminate), and the second time in Desktop::doShutdown. The second event happens after application's Basic manager already was destroyed in SfxApplication::Deinitialize. The Basic provider, which holds a pointer to the manager, doesn't properly cleanup upon the manager's destruction, thus trying to use it after free. This removes the second (duplicate) generated OnCloseApp event, and makes BasicProviderImpl inherit from SfxListener to allow receiving the manager's SfxHintId::Dying notification. Change-Id: Iabf1432c41b1925b11b5a89e5fd8a6ae8249831e Reviewed-on: https://gerrit.libreoffice.org/62810 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- scripting/source/basprov/basprov.hxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripting/source/basprov/basprov.hxx') diff --git a/scripting/source/basprov/basprov.hxx b/scripting/source/basprov/basprov.hxx index b3ba2617982c..d10f10e7e970 100644 --- a/scripting/source/basprov/basprov.hxx +++ b/scripting/source/basprov/basprov.hxx @@ -29,6 +29,7 @@ #include #include #include +#include class BasicManager; @@ -47,7 +48,7 @@ namespace basprov css::script::browse::XBrowseNode > BasicProviderImpl_BASE; - class BasicProviderImpl : public BasicProviderImpl_BASE + class BasicProviderImpl : public BasicProviderImpl_BASE, public SfxListener { private: BasicManager* m_pAppBasicManager; @@ -86,6 +87,10 @@ namespace basprov virtual css::uno::Sequence< css::uno::Reference< css::script::browse::XBrowseNode > > SAL_CALL getChildNodes( ) override; virtual sal_Bool SAL_CALL hasChildNodes( ) override; virtual sal_Int16 SAL_CALL getType( ) override; + + protected: + // SfxListener + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint) override; }; -- cgit