sfx2/source/doc/sfxbasemodel.cxx |   22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 3746235c671d044e1b5662bcfb36560415b28711
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 17:57: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 8dda903183a3..d68830211d5d 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3136,18 +3136,19 @@ public:
 
 void SfxBaseModel::postEvent_Impl( const OUString& aName, const Reference< 
frame::XController2 >& xController )
 {
-    // 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;
 
     ::cppu::OInterfaceContainerHelper* pIC =
@@ -3176,7 +3177,6 @@ void SfxBaseModel::postEvent_Impl( const OUString& aName, 
const Reference< frame
                 &document::XEventListener::notifyEvent,
                 aEvent ) );
     }
-
 }
 
 Reference < container::XIndexAccess > SAL_CALL SfxBaseModel::getViewData()
commit 9d5f1b02b0d349f86a8b8b3c54b525bf9fe98f0d
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 17:57:58 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.
    
    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)
    
    Plus this file's part of commit b9fe4f26eaf1099b8d0907b8d9cbf52c86914466
    "rename some local variables".
    
    Change-Id: Icdb6c841408254142561db408f876618adbc0b76

diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index 353161ef9a8e..8dda903183a3 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -3141,17 +3141,17 @@ void SfxBaseModel::postEvent_Impl( const OUString& 
aName, const Reference< frame
         return;
 
     // keep m_pData alive, if notified target would dispose the document
-    std::shared_ptr<IMPL_SfxBaseModel_DataContainer> pData(m_pData);
+    std::shared_ptr<IMPL_SfxBaseModel_DataContainer> xKeepAlive(m_pData);
 
     // also make sure this object doesn't self-destruct while notifying
-    rtl::Reference<SfxBaseModel> self(this);
+    rtl::Reference<SfxBaseModel> xHoldAlive(this);
 
     DBG_ASSERT( !aName.isEmpty(), "Empty event name!" );
     if (aName.isEmpty())
         return;
 
     ::cppu::OInterfaceContainerHelper* 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);
@@ -3164,7 +3164,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);

Reply via email to