sw/inc/docufld.hxx                |    1 +
 sw/source/core/fields/docufld.cxx |   15 ++++++++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

New commits:
commit 95e52cb1a7aea859bb5d8e6b9c02b928fb884f77
Author:     Samuel Mehrbrodt <[email protected]>
AuthorDate: Mon Mar 23 22:07:34 2026 +0100
Commit:     Michael Stahl <[email protected]>
CommitDate: Tue Mar 24 18:21:03 2026 +0100

    Prevent warnings when loading doc with placeholder fields
    
    Warning seen on load:
      warn:sw.core:650487:650487:sw/source/core/attr/format.cxx:197: ~SwFormat: 
format still has clients on death, but parent format is missing: Character style
    
    Changes done:
    - Prevent accumulating duplicate listener entries.
      Each call was blindly adding a new ListenerEntry - resulting in duplicate 
entries when multiple placeholders were in the doc
    - When the char format we were listening to was destroyed: stop listening
      rather than staying reparented on its parent format.
    
    Change-Id: Iccc774ea929e3ac61ccabc0e08b6fb9f81b26505
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/202430
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index cec184b43af3..f00646b276b1 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -739,6 +739,7 @@ class SwJumpEditFieldType final : public SwFieldType
 public:
     SwJumpEditFieldType( SwDoc& rDoc );
     virtual std::unique_ptr<SwFieldType> Copy() const override;
+    virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
     virtual void UpdateFields() override {};
 
     SwCharFormat* GetCharFormat();
diff --git a/sw/source/core/fields/docufld.cxx 
b/sw/source/core/fields/docufld.cxx
index 80fa2c4da316..b2b5d65116e5 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -2643,10 +2643,23 @@ std::unique_ptr<SwFieldType> 
SwJumpEditFieldType::Copy() const
     return std::make_unique<SwJumpEditFieldType>( m_rDoc );
 }
 
+void SwJumpEditFieldType::SwClientNotify(const SwModify& rModify, const 
SfxHint& rHint)
+{
+    if (rHint.GetId() == SfxHintId::SwModifyChanged)
+    {
+        // The char format we were listening to was destroyed; stop listening
+        // rather than staying reparented on its parent format.
+        m_aDep.EndListeningAll();
+        return;
+    }
+    SwFieldType::SwClientNotify(rModify, rHint);
+}
+
 SwCharFormat* SwJumpEditFieldType::GetCharFormat()
 {
     SwCharFormat* pFormat = 
m_rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( 
RES_POOLCHR_JUMPEDIT );
-    m_aDep.StartListening(pFormat);
+    if (!m_aDep.IsListeningTo(pFormat))
+        m_aDep.StartListening(pFormat);
     return pFormat;
 }
 

Reply via email to