diff options
-rw-r--r-- | include/sfx2/sfxbasemodel.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/doc/sfxbasemodel.cxx | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx index e721a77e35f4..03ee06484869 100644 --- a/include/sfx2/sfxbasemodel.hxx +++ b/include/sfx2/sfxbasemodel.hxx @@ -738,7 +738,7 @@ private: private: - std::unique_ptr<IMPL_SfxBaseModel_DataContainer> m_pData; + std::shared_ptr<IMPL_SfxBaseModel_DataContainer> m_pData; // cannot be held in m_pData, since it needs to be accessed in non-threadsafe context const bool m_bSupportEmbeddedScripts; const bool m_bSupportDocRecovery; diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index 2403ca27d212..7cb1076485a5 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3058,6 +3058,12 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame if ( impl_isDisposed() ) return; + // keep m_pData alive, if notified target would dispose the document + std::shared_ptr<IMPL_SfxBaseModel_DataContainer> pData(m_pData); + + // also make sure this object doesn't self-destruct while notifying + rtl::Reference<SfxBaseModel> self(this); + DBG_ASSERT( !aName.isEmpty(), "Empty event name!" ); if (aName.isEmpty()) return; |