[Libreoffice-commits] core.git: Branch 'libreoffice-6-3' - sw/source

Michael Stahl (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 27 13:55:40 UTC 2019


 sw/source/core/unocore/unofield.cxx |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

New commits:
commit 18a92a86906d3f68e7cdebb2c55122f735b4f10e
Author:     Michael Stahl <Michael.Stahl at cib.de>
AuthorDate: Wed Jun 26 14:02:59 2019 +0200
Commit:     Michael Stahl <Michael.Stahl at cib.de>
CommitDate: Thu Jun 27 15:54:51 2019 +0200

    sw: fix SwXTextField::Impl::IsDescriptor()
    
    ... to return false for a disposed instance.
    
    Follow-up to 36defda96fc62cef1e1ffb725f6768d54b0d9cd0
    
    Unfortrunately have to resurrect the boolean flag again, because neither
    m_pDoc nor m_pFieldType can be used to check.
    
    (regression from e18359445fabad9ba1a704600e9ee327112cc6ae)
    
    Change-Id: I6009cb39cd49b930e042aa21f4b40877c4fdbdde
    Reviewed-on: https://gerrit.libreoffice.org/74739
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <Michael.Stahl at cib.de>
    (cherry picked from commit 459de9c585505b43acd184c00a0251bf7a7c8768)
    Reviewed-on: https://gerrit.libreoffice.org/74792

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 8433440aa9ff..0cbf59a13931 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -1131,6 +1131,7 @@ public:
 
     SwDoc* m_pDoc;
     rtl::Reference<SwTextAPIObject> m_xTextObject;
+    bool m_bIsDescriptor;
     bool m_bCallUpdate;
     SwServiceType const m_nServiceId;
     OUString m_sTypeName;
@@ -1140,6 +1141,7 @@ public:
         : m_pFormatField(pFormat)
         , m_EventListeners(m_Mutex)
         , m_pDoc(pDoc)
+        , m_bIsDescriptor(pFormat == nullptr)
         , m_bCallUpdate(false)
         , m_nServiceId(pFormat
                 ? lcl_GetServiceForField(*pFormat->GetField())
@@ -1174,7 +1176,9 @@ public:
     }
     bool IsDescriptor() const
     {
-        return !m_pFormatField;
+        // ideally should be: !m_pFormatField && m_pDoc
+        // but: SwXServiceProvider::MakeInstance() passes nullptr SwDoc, see comment there
+        return m_bIsDescriptor;
     }
     void Invalidate();
 
@@ -2037,6 +2041,7 @@ void SAL_CALL SwXTextField::attach(
     m_pImpl->m_pDoc = pDoc;
     m_pImpl->GetFormatField()->SetXTextField(this);
     m_pImpl->m_wThis = *this;
+    m_pImpl->m_bIsDescriptor = false;
     m_pImpl->ClearFieldType();
     m_pImpl->m_pProps.reset();
     if (m_pImpl->m_bCallUpdate)
@@ -2231,7 +2236,8 @@ SwXTextField::setPropertyValue(
         }
 
         //#i100374# notify SwPostIt about new field content
-        if (SwFieldIds::Postit == nWhich && !m_pImpl->IsDescriptor())
+        assert(m_pImpl->GetFormatField());
+        if (SwFieldIds::Postit == nWhich)
         {
             m_pImpl->GetFormatField()->Broadcast(
                     SwFormatFieldHint( nullptr, SwFormatFieldHintWhich::CHANGED ));
@@ -2677,7 +2683,7 @@ void SwXTextField::Impl::Notify(const SfxHint& rHint)
 
 const SwField* SwXTextField::Impl::GetField() const
 {
-    return IsDescriptor() ? nullptr : m_pFormatField->GetField();
+    return m_pFormatField ? m_pFormatField->GetField() : nullptr;
 }
 
 OUString SwXTextFieldMasters::getImplementationName()


More information about the Libreoffice-commits mailing list