sw/source/uibase/utlui/content.cxx |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

New commits:
commit b2500f0e32b33eec2740dc370238f66fb8b50ffb
Author:     Jim Raykowski <rayk...@gmail.com>
AuthorDate: Fri Jan 12 23:56:43 2024 -0900
Commit:     Jim Raykowski <rayk...@gmail.com>
CommitDate: Wed Jan 17 16:48:22 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>

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)
             {

Reply via email to