From a7a3ec9b3d150039e14fe5043bad4d2fa47bfd13 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Mon, 23 Feb 2026 08:21:01 -0800 Subject: [PATCH 1/3] Fix LT-22355: Crash after typing a letter in Find dialog box --- Src/xWorks/XhtmlDocView.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Src/xWorks/XhtmlDocView.cs b/Src/xWorks/XhtmlDocView.cs index 849e62d2d8..cedc22636d 100644 --- a/Src/xWorks/XhtmlDocView.cs +++ b/Src/xWorks/XhtmlDocView.cs @@ -1291,6 +1291,11 @@ private void FindNextInBrowser(object sender, IBasicFindView view) private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindView view, string lastId) { + if (geckoBrowser.Document == null) + { + Close(); + return; + } if (results != null && results.Length > 0) { view.StatusText = $"{resultIndex + 1} of {results.Length} Results"; @@ -1308,7 +1313,7 @@ private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindVi private void ClearCurrentFindResult(GeckoWebBrowser geckoBrowser, string lastId) { - var currentElement = geckoBrowser.Document.GetHtmlElementById(lastId); + var currentElement = geckoBrowser.Document?.GetHtmlElementById(lastId); if (currentElement != null) docView.RemoveClassFromHtmlElement(currentElement, CurrentSelectedEntryClass); } @@ -1321,6 +1326,12 @@ private bool InitResults(string searchText) if (results == null || results.Length == 0) { string newResults = string.Empty; + if (geckoBrowser.Document == null) + { + results = newResults.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + resultIndex = 0; + return true; + } geckoBrowser.RemoveMessageEventListener("find"); geckoBrowser.AddMessageEventListener("find", r => newResults = r); using(var executor = new AutoJSContext(geckoBrowser.Window)) From 123a39383079813df9220484bbda5dfe62424b8a Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Mon, 23 Feb 2026 09:09:35 -0800 Subject: [PATCH 2/3] Report lack of document instead of closing --- Src/xWorks/XhtmlDocView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/xWorks/XhtmlDocView.cs b/Src/xWorks/XhtmlDocView.cs index cedc22636d..7c1c122b9c 100644 --- a/Src/xWorks/XhtmlDocView.cs +++ b/Src/xWorks/XhtmlDocView.cs @@ -1293,7 +1293,7 @@ private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindVi { if (geckoBrowser.Document == null) { - Close(); + view.StatusText = "No Document"; return; } if (results != null && results.Length > 0) From b86add269f29f8b5a43c9f0b8d300a3a47759491 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Wed, 25 Feb 2026 08:07:58 -0800 Subject: [PATCH 3/3] Simplifying to results = null eliminates need for "No Document" --- Src/xWorks/XhtmlDocView.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Src/xWorks/XhtmlDocView.cs b/Src/xWorks/XhtmlDocView.cs index 7c1c122b9c..ce2e94dc02 100644 --- a/Src/xWorks/XhtmlDocView.cs +++ b/Src/xWorks/XhtmlDocView.cs @@ -1291,11 +1291,6 @@ private void FindNextInBrowser(object sender, IBasicFindView view) private void ScrollAndHighlightResult(GeckoWebBrowser geckoBrowser, IBasicFindView view, string lastId) { - if (geckoBrowser.Document == null) - { - view.StatusText = "No Document"; - return; - } if (results != null && results.Length > 0) { view.StatusText = $"{resultIndex + 1} of {results.Length} Results"; @@ -1328,7 +1323,7 @@ private bool InitResults(string searchText) string newResults = string.Empty; if (geckoBrowser.Document == null) { - results = newResults.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); + results = null; resultIndex = 0; return true; }