diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-03-31 19:01:25 +0200 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-03-31 20:08:57 +0200 |
commit | fae6699c2ec8d68766bb8d5f71483d4b65792327 (patch) | |
tree | e04ac98a337173bc74fafc803e46b50bba8742bf | |
parent | sw: fix obscure crash in SwXTextDocument::getSomething() (diff) | |
download | core-fae6699c2ec8d68766bb8d5f71483d4b65792327.tar.gz core-fae6699c2ec8d68766bb8d5f71483d4b65792327.zip |
sfx2: fix VBA crash when disposing SfxBaseModel
Crash on WNT in CppunitTest_sw_globalfilter testSkipImages()
SfxBaseModel::dispose() calls some event listener that deletes the
BasicManager instance; unfortunately SfxObjectShell_Impl has a
SfxBasicHolder member that still refers to the deleted BasicManager
and then something calls vba::getVBAServiceFactory()...
Try to fix that by clearing the SfxBasicHolder member via SfxListener.
Change-Id: I65f2ec8e9eb598be218136c06ed8de35a464a971
-rw-r--r-- | sfx2/source/appl/appbaslib.cxx | 14 | ||||
-rw-r--r-- | sfx2/source/inc/appbaslib.hxx | 4 |
2 files changed, 18 insertions, 0 deletions
diff --git a/sfx2/source/appl/appbaslib.cxx b/sfx2/source/appl/appbaslib.cxx index 980f2db2bdc8..e22091705898 100644 --- a/sfx2/source/appl/appbaslib.cxx +++ b/sfx2/source/appl/appbaslib.cxx @@ -43,6 +43,19 @@ SfxBasicManagerHolder::SfxBasicManagerHolder() { } +void SfxBasicManagerHolder::Notify(SfxBroadcaster& rBC, SfxHint const& rHint) +{ + if (!mpBasicManager || &rBC != mpBasicManager) + return; + SfxSimpleHint const*const pSimpleHint(dynamic_cast<SfxSimpleHint const*>(&rHint)); + if (pSimpleHint && SFX_HINT_DYING == pSimpleHint->GetId()) + { + mpBasicManager = nullptr; + mxBasicContainer.clear(); + mxDialogContainer.clear(); + } +} + void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager ) { impl_releaseContainers(); @@ -59,6 +72,7 @@ void SfxBasicManagerHolder::reset( BasicManager* _pBasicManager ) if ( mpBasicManager ) { + StartListening(*mpBasicManager); try { mxBasicContainer.set( mpBasicManager->GetScriptLibraryContainer(), UNO_QUERY_THROW ); diff --git a/sfx2/source/inc/appbaslib.hxx b/sfx2/source/inc/appbaslib.hxx index 5810afdbb789..8e0d5f84bb19 100644 --- a/sfx2/source/inc/appbaslib.hxx +++ b/sfx2/source/inc/appbaslib.hxx @@ -20,6 +20,8 @@ #ifndef INCLUDED_SFX2_SOURCE_INC_APPBASLIB_HXX #define INCLUDED_SFX2_SOURCE_INC_APPBASLIB_HXX +#include <svl/lstner.hxx> + #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/script/XStorageBasedLibraryContainer.hpp> #include <com/sun/star/embed/XStorage.hpp> @@ -29,6 +31,7 @@ class BasicManager; /** helper class which holds and manipulates a BasicManager */ class SfxBasicManagerHolder + : public SfxListener { private: BasicManager* mpBasicManager; @@ -84,6 +87,7 @@ public: */ bool LegacyPsswdBinaryLimitExceeded( ::com::sun::star::uno::Sequence< OUString >& sModules ); + virtual void Notify(SfxBroadcaster& rBC, SfxHint const& rHint) SAL_OVERRIDE; private: void impl_releaseContainers(); |