[Libreoffice-commits] core.git: include/sfx2 sfx2/source

Thorsten Behrens Thorsten.Behrens at CIB.de
Sat Jan 27 22:31:54 UTC 2018


 include/sfx2/sfxbasemodel.hxx    |    2 +-
 sfx2/source/doc/sfxbasemodel.cxx |    3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 1841fcf896f50b7df1375d431857ecddd5f5b392
Author: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Date:   Fri Jan 26 16:13:23 2018 +0100

    tdf#115090 keep internal BaseModel alive long enough
    
    There's reams of code already preventing a close during save
    (SfxSaveGuard), but this looks equally effective. Avoids
    SfxBaseModel::dispose() pulling the rug under us, when
    SfxBaseModel::postEvent_Impl() wants to access parts of the
    interface containers during notification.
    
    Change-Id: Iace1f9922c47a97ab2e798b577c6aec8a729da48
    Reviewed-on: https://gerrit.libreoffice.org/48709
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/include/sfx2/sfxbasemodel.hxx b/include/sfx2/sfxbasemodel.hxx
index e383a3de0dd0..33c8b4b1e3c2 100644
--- a/include/sfx2/sfxbasemodel.hxx
+++ b/include/sfx2/sfxbasemodel.hxx
@@ -739,7 +739,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 4a733eeefd3c..d57fe3435f85 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3062,6 +3062,9 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame
     if ( impl_isDisposed() )
         return;
 
+    // keep m_pData alive, if notified target would close the document
+    std::shared_ptr<IMPL_SfxBaseModel_DataContainer> pData(m_pData);
+
     DBG_ASSERT( !aName.isEmpty(), "Empty event name!" );
     if (aName.isEmpty())
         return;


More information about the Libreoffice-commits mailing list