mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-06 05:59:41 -06:00
GP-6254 - Fixed NPE in function graph middle-mouse highlighter
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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<Component> 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<Component> 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<Component> repaintSupplier;
|
||||
|
||||
public FgMiddleMouseHighlightProvider(PluginTool tool,
|
||||
Supplier<Component> repaintSupplier) {
|
||||
super(tool, null);
|
||||
this.repaintSupplier = repaintSupplier;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repaint() {
|
||||
Component c = repaintSupplier.get();
|
||||
if (c != null) {
|
||||
c.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,7 +216,7 @@
|
||||
<H2> Formatting </H2>
|
||||
<P> 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 <I><B>support/eclipse/</B></I>
|
||||
directory of a Ghidra release, or in the <I><B>eclipse/</B><I> directory of the Ghidra
|
||||
directory of a Ghidra release, or in the <I><B>eclipse/</B></I> directory of the Ghidra
|
||||
source repository.
|
||||
<H3> Line Length </H3>
|
||||
<H4> Java code will have a character limit of 100 characters per line. </H4>
|
||||
|
||||
Reference in New Issue
Block a user