sw/source/uibase/utlui/content.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
New commits: commit 421f5394c29763a4f766a4fe4656bb948979ee1d Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Fri Jan 12 23:56:43 2024 -0900 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Wed Jan 17 20:27:01 2024 +0100 tdf#159147 Fix crash when editing hyperlink while navigator is open by assuring the SwURLFieldContent::SwTextINetFormat pointer is still valid before trying to bring the hyperlink content to attention Change-Id: I7f672576ab2869c5483284b543e99e46a558acc9 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162013 Tested-by: Jenkins Tested-by: Xisco Fauli <xiscofa...@libreoffice.org> Reviewed-by: Jim Raykowski <rayk...@gmail.com> (cherry picked from commit b2500f0e32b33eec2740dc370238f66fb8b50ffb) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162213 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index cd6528752fef..f5af1e759738 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -5662,8 +5662,24 @@ void SwContentTree::BringEntryToAttention(const weld::TreeIter& rEntry) } else if (nType == ContentTypeId::URLFIELD) { - BringURLFieldsToAttention(SwGetINetAttrs {SwGetINetAttr(pCnt->GetName(), - *static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr())}); + // tdf#159147 - Assure the SwURLFieldContent::SwTextINetFormat pointer is valid + // before bringing to attention. + const SwTextINetFormat* pTextINetFormat + = static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr(); + const SwCharFormats* pFormats = m_pActiveShell->GetDoc()->GetCharFormats(); + for (auto n = pFormats->size(); 1 < n;) + { + SwIterator<SwTextINetFormat, SwCharFormat> aIter(*(*pFormats)[--n]); + for (SwTextINetFormat* pFnd = aIter.First(); pFnd; pFnd = aIter.Next() ) + { + if (pTextINetFormat == pFnd) + { + BringURLFieldsToAttention(SwGetINetAttrs {SwGetINetAttr(pCnt->GetName(), + *pTextINetFormat)}); + break; + } + } + } } else if (nType == ContentTypeId::REFERENCE) {