From d9b2861d0ee8e2fc43f09e75f2e0078b1327aa6e Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Thu, 23 Jan 2025 10:43:33 -0500 Subject: [PATCH] Test fix --- .../docking/widgets/TextComponentSearcher.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/TextComponentSearcher.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/TextComponentSearcher.java index 58dc2641d9..76c9adcd68 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/TextComponentSearcher.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/TextComponentSearcher.java @@ -16,8 +16,9 @@ package docking.widgets; import java.awt.*; -import java.util.*; +import java.util.Collection; import java.util.Map.Entry; +import java.util.TreeMap; import java.util.regex.*; import javax.swing.JEditorPane; @@ -66,6 +67,8 @@ public class TextComponentSearcher implements FindDialogSearcher { public void setEditorPane(JEditorPane editorPane) { if (this.editorPane != editorPane) { + Document document = editorPane.getDocument(); + document.removeDocumentListener(documentListener); markResultsStale(); } this.editorPane = editorPane; @@ -79,10 +82,12 @@ public class TextComponentSearcher implements FindDialogSearcher { public void dispose() { caretUpdater.dispose(); - Document document = editorPane.getDocument(); - document.removeDocumentListener(documentListener); + if (editorPane != null) { + Document document = editorPane.getDocument(); + document.removeDocumentListener(documentListener); - clearHighlights(); + clearHighlights(); + } } @Override @@ -253,9 +258,7 @@ public class TextComponentSearcher implements FindDialogSearcher { return; } - Iterator it = matchesByPosition.values().iterator(); - while (it.hasNext()) { - FindMatch match = it.next(); + for (FindMatch match : matchesByPosition.values()) { boolean isActive = false; if (match.contains(pos)) { activeMatch = match;