diff options
author | Jim Raykowski <raykowj@gmail.com> | 2024-01-12 23:56:43 -0900 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2024-01-17 16:48:22 +0100 |
commit | b2500f0e32b33eec2740dc370238f66fb8b50ffb (patch) | |
tree | c0098c05b310c60575e36fb4ebdeb36624ec51ec /sw/source/uibase | |
parent | 5bc1d4bea295695b193cab61b92ba89bcbe169cd (diff) |
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 <xiscofauli@libreoffice.org>
Reviewed-by: Jim Raykowski <raykowj@gmail.com>
Diffstat (limited to 'sw/source/uibase')
-rw-r--r-- | sw/source/uibase/utlui/content.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sw/source/uibase/utlui/content.cxx b/sw/source/uibase/utlui/content.cxx index 2f0bdc06f739..c5f2b3e3afa9 100644 --- a/sw/source/uibase/utlui/content.cxx +++ b/sw/source/uibase/utlui/content.cxx @@ -6092,8 +6092,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) { |