sw/source/core/docnode/node.cxx | 18 ++++++++++++++++-- sw/source/core/txtnode/ndtxt.cxx | 2 +- sw/source/core/txtnode/thints.cxx | 4 ++-- sw/source/core/txtnode/txtedt.cxx | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-)
New commits: commit 2bce53f785909173210af45df1eba7c702c98a61 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Mon Dec 30 16:09:42 2024 +0100 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Mon Dec 30 17:21:28 2024 +0100 Revert "simplify RES_UPDATE_ATTR handling" This reverts commit c854c09ed109b650b5b5faaafcc8c202860ff39e. Reason for revert: The call sites that pass pOld == nullptr and pNew == something, are effectively passing a flag to SwRegHistory::SwClientNotify Change-Id: I58e71e7439893061d598aecef3a91f5f2d0897f9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179566 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx index e3e3c6a03edf..054176a7682a 100644 --- a/sw/source/core/docnode/node.cxx +++ b/sw/source/core/docnode/node.cxx @@ -1164,9 +1164,23 @@ void SwContentNode::SwClientNotify( const SwModify&, const SfxHint& rHint) break; case RES_UPDATE_ATTR: - assert(pLegacyHint->m_pNew && pLegacyHint->m_pNew == pLegacyHint->m_pOld); + // RES_UPDATE_ATTR _should_ always contain a SwUpdateAttr hint in old and new. + // However, faking one with just a basic SfxPoolItem setting a WhichId has been observed. + // This makes the crude "WhichId" type divert from the true type, which is bad. + // Thus we are asserting here, but falling back to an proper + // hint instead. so that we at least will not spread such poison further. +#ifdef DBG_UTIL + if (!SfxPoolItem::areSame(pLegacyHint->m_pNew, pLegacyHint->m_pOld)) + { + auto pBT = sal::backtrace_get(20); + SAL_WARN("sw.core", "UpdateAttr not matching! " << sal::backtrace_to_string(pBT.get())); + } +#endif + assert(SfxPoolItem::areSame(pLegacyHint->m_pNew, pLegacyHint->m_pOld)); assert(dynamic_cast<const SwUpdateAttr*>(pLegacyHint->m_pNew)); - UpdateAttr(*static_cast<const SwUpdateAttr*>(pLegacyHint->m_pNew)); + const SwUpdateAttr aFallbackHint(0,0,0); + const SwUpdateAttr& rUpdateAttr = pLegacyHint->m_pNew ? *static_cast<const SwUpdateAttr*>(pLegacyHint->m_pNew) : aFallbackHint; + UpdateAttr(rUpdateAttr); return; } if(bCalcHidden) diff --git a/sw/source/core/txtnode/ndtxt.cxx b/sw/source/core/txtnode/ndtxt.cxx index e4217a9b1079..74981b929be9 100644 --- a/sw/source/core/txtnode/ndtxt.cxx +++ b/sw/source/core/txtnode/ndtxt.cxx @@ -2925,7 +2925,7 @@ void SwTextNode::GCAttr() nMax, 0); - CallSwClientNotify(sw::LegacyModifyHint(&aHint, &aHint)); + CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); CallSwClientNotify(SwFormatChangeHint(nullptr, GetTextColl())); } } diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx index 4068ed401e21..5285fd9e75cb 100644 --- a/sw/source/core/txtnode/thints.cxx +++ b/sw/source/core/txtnode/thints.cxx @@ -1802,7 +1802,7 @@ void SwTextNode::DeleteAttribute( SwTextAttr * const pAttr ) m_pSwpHints->Delete( pAttr ); SwTextAttr::Destroy( pAttr ); - CallSwClientNotify(sw::LegacyModifyHint(&aHint, &aHint)); + CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); TryDeleteSwpHints(); } @@ -1877,7 +1877,7 @@ void SwTextNode::DeleteAttributes( m_pSwpHints->DeleteAtPos( nPos ); SwTextAttr::Destroy( pTextHt ); - CallSwClientNotify(sw::LegacyModifyHint(&aHint, &aHint)); + CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); } } } diff --git a/sw/source/core/txtnode/txtedt.cxx b/sw/source/core/txtnode/txtedt.cxx index 7f321e109518..df0582e1f058 100644 --- a/sw/source/core/txtnode/txtedt.cxx +++ b/sw/source/core/txtnode/txtedt.cxx @@ -668,7 +668,7 @@ void SwTextNode::RstTextAttr( nMax, 0); - CallSwClientNotify(sw::LegacyModifyHint(&aHint, &aHint)); + CallSwClientNotify(sw::LegacyModifyHint(nullptr, &aHint)); CallSwClientNotify(SwFormatChangeHint(nullptr, GetFormatColl())); }