sfx2/source/doc/sfxbasemodel.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
New commits: commit a7fa60410667da4cecd571652b12da0e4909a6f8 Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Tue Jan 9 16:44:50 2024 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jan 9 18:08:58 2024 +0100 sfx2: reorder the checks in SfxBaseModel::postEvent_Impl() It doesn't make sense to copy m_pData after impl_isDisposed() checks if it's null (not sure if this makes a difference in practice). Change-Id: I5c6db0bd3e09f92acef346115a4fee44ae4c0a89 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161835 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> (cherry picked from commit 79e8f18f635dfd094485ed18166fd8b04c37862c) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index b83fb2f07d56..0236fe929dbf 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3236,18 +3236,19 @@ public: void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame::XController2 >& xController, const Any& supplement ) { - // object already disposed? - if ( impl_isDisposed() ) + if (aName.isEmpty()) + { + SAL_WARN("sfx.doc", "postEvent_Impl: Empty event name!"); return; - - // keep m_pData alive, if notified target would dispose the document - std::shared_ptr<IMPL_SfxBaseModel_DataContainer> xKeepAlive(m_pData); + } // also make sure this object doesn't self-destruct while notifying rtl::Reference<SfxBaseModel> xHoldAlive(this); + // keep m_pData alive, if notified target would dispose the document + std::shared_ptr<IMPL_SfxBaseModel_DataContainer> xKeepAlive(m_pData); - DBG_ASSERT( !aName.isEmpty(), "Empty event name!" ); - if (aName.isEmpty()) + // object already disposed? + if ( impl_isDisposed() ) return; comphelper::OInterfaceContainerHelper2* pIC = @@ -3276,7 +3277,6 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame &document::XEventListener::notifyEvent, aEvent ) ); } - } Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData() commit 5e488787312a2f42bdc080accda6d04dc2e6496d Author: Armin Le Grand (allotropia) <armin.le.grand.ext...@allotropia.de> AuthorDate: Fri Dec 16 16:57:46 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Tue Jan 9 18:08:36 2024 +0100 Use xKeepAlive instead of m_pData There is already an instance to keep the incarnation alive, but it was not used. Instead m_pData can indeed get deleted (nullptr), so better use the alive one. Change-Id: Icdb6c841408254142561db408f876618adbc0b76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144340 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> (cherry picked from commit 8635c9aa8c6f1078a9e220076d5a08daf30077e8) diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx index dc9a056e31bb..b83fb2f07d56 100644 --- a/sfx2/source/doc/sfxbasemodel.cxx +++ b/sfx2/source/doc/sfxbasemodel.cxx @@ -3251,7 +3251,7 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame return; comphelper::OInterfaceContainerHelper2* pIC = - m_pData->m_aInterfaceContainer.getContainer( cppu::UnoType<document::XDocumentEventListener>::get()); + xKeepAlive->m_aInterfaceContainer.getContainer( cppu::UnoType<document::XDocumentEventListener>::get()); if ( pIC ) { SAL_INFO("sfx.doc", "SfxDocumentEvent: " + aName); @@ -3264,7 +3264,7 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< frame aDocumentEvent ) ); } - pIC = m_pData->m_aInterfaceContainer.getContainer( cppu::UnoType<document::XEventListener>::get()); + pIC = xKeepAlive->m_aInterfaceContainer.getContainer( cppu::UnoType<document::XEventListener>::get()); if ( pIC ) { SAL_INFO("sfx.doc", "SfxEvent: " + aName);