diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java index 0ce143b404..45e6579691 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/codebrowser/ListingMiddleMouseHighlightProvider.java @@ -207,13 +207,17 @@ public class ListingMiddleMouseHighlightProvider currentHighlightString = highlightString; + repaint(); + } + + protected void repaint() { repaintComponent.repaint(); } private void clearHighlight() { currentHighlightString = null; currentHighlightPattern = null; - repaintComponent.repaint(); + repaint(); } private Pattern createRegisterPattern(Register register, String... highlightStrings) { diff --git a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java index fc45fa4f96..045c1f47e5 100644 --- a/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java +++ b/Ghidra/Features/FunctionGraph/src/main/java/ghidra/app/plugin/core/functiongraph/mvc/FGController.java @@ -21,6 +21,7 @@ import java.awt.geom.Point2D; import java.util.*; import java.util.List; import java.util.function.BiConsumer; +import java.util.function.Supplier; import javax.swing.JComponent; @@ -196,9 +197,10 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi return sharedHighlightProvider; } - JComponent centerOverComponent = view.getPrimaryGraphViewer(); - sharedHighlightProvider = - new FgHighlightProvider(env.getTool(), centerOverComponent); + // At the time of construction, the view has not yet built the graph viewer. We will use a + // supplier to access the viewer on demand. It should be valid at that point. + Supplier repaintSupplier = () -> view.getPrimaryGraphViewer(); + sharedHighlightProvider = new FgHighlightProvider(env.getTool(), repaintSupplier); return sharedHighlightProvider; } @@ -1157,10 +1159,10 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi private static class FgHighlightProvider implements ListingHighlightProvider, ButtonPressedListener { - private ListingMiddleMouseHighlightProvider highlighter; + private FgMiddleMouseHighlightProvider highlighter; - FgHighlightProvider(PluginTool tool, Component repaintComponent) { - highlighter = new ListingMiddleMouseHighlightProvider(tool, repaintComponent); + FgHighlightProvider(PluginTool tool, Supplier repaintSupplier) { + highlighter = new FgMiddleMouseHighlightProvider(tool, repaintSupplier); } @Override @@ -1173,5 +1175,24 @@ public class FGController implements ProgramLocationListener, ProgramSelectionLi ListingField field, MouseEvent event) { highlighter.buttonPressed(location, fieldLocation, field, event); } + + private class FgMiddleMouseHighlightProvider extends ListingMiddleMouseHighlightProvider { + + private Supplier repaintSupplier; + + public FgMiddleMouseHighlightProvider(PluginTool tool, + Supplier repaintSupplier) { + super(tool, null); + this.repaintSupplier = repaintSupplier; + } + + @Override + protected void repaint() { + Component c = repaintSupplier.get(); + if (c != null) { + c.repaint(); + } + } + } } } diff --git a/GhidraDocs/GhidraCodingStandards.html b/GhidraDocs/GhidraCodingStandards.html index e0e49fe096..d2dc635bd7 100644 --- a/GhidraDocs/GhidraCodingStandards.html +++ b/GhidraDocs/GhidraCodingStandards.html @@ -216,7 +216,7 @@

Formatting

Most of these are handled by the Eclipse formatter and are here to document the Ghidra formatting style. The Eclipse formatter can be found in the support/eclipse/ - directory of a Ghidra release, or in the eclipse/ directory of the Ghidra + directory of a Ghidra release, or in the eclipse/ directory of the Ghidra source repository.

Line Length

Java code will have a character limit of 100 characters per line.