sw/source/uibase/utlui/content.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
New commits: commit 553b91ef4204d0d6473f45ceadb76d6e24a08879 Author: Jim Raykowski <rayk...@gmail.com> AuthorDate: Fri Jan 12 23:56:43 2024 -0900 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Jan 24 09:27:42 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/+/162212 Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> (cherry picked from commit a6ce9960c37928cb8a27383dc8e10125011131c9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162216 Reviewed-by: Hossein <hoss...@libreoffice.org> Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakan...@libreoffice.org> Tested-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 72fd76cbe1ce..3bf29979ddf3 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -6077,8 +6077,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) {