GP-3047 - fixed potential npe due to a timing issue

This commit is contained in:
dragonmacher 2023-01-24 13:30:35 -05:00
parent 3e03a86117
commit 5da5ec3b6d

View file

@ -33,11 +33,11 @@ import ghidra.graph.viewer.event.mouse.VertexMouseInfo;
* A base component provider for displaying {@link VisualGraph}s
*
* <p>This class will provide many optional sub-features, enabled as desired by calling the
* various <code>addXyzFeature()</code> methods.
* various <code>addXyzFeature()</code> methods.
*
* <p>Implementation Notes: to get full functionality, you must:
* <ul>
* <li>Have your plugin call {@link #readConfigState(SaveState)} and
* <li>Have your plugin call {@link #readConfigState(SaveState)} and
* {@link #writeConfigState(SaveState)} to save user settings.
* </li>
* <li>Enable features you desire after calling your {@link #addToTool()} method.
@ -49,9 +49,9 @@ import ghidra.graph.viewer.event.mouse.VertexMouseInfo;
* @param <G> the graph type
*/
//@formatter:off
public abstract class VisualGraphComponentProvider<V extends VisualVertex,
E extends VisualEdge<V>,
G extends VisualGraph<V, E>>
public abstract class VisualGraphComponentProvider<V extends VisualVertex,
E extends VisualEdge<V>,
G extends VisualGraph<V, E>>
extends ComponentProvider {
//@formatter:on
@ -104,6 +104,10 @@ public abstract class VisualGraphComponentProvider<V extends VisualVertex,
public Set<V> getSelectedVertices() {
VisualGraphView<V, E, G> view = getView();
VisualizationViewer<V, E> viewer = view.getPrimaryGraphViewer();
if (viewer == null) {
// we have seen this happen on some systems; timing issue?
return Collections.emptySet();
}
PickedState<V> pickedState = viewer.getPickedVertexState();
return pickedState.getPicked();
}
@ -127,7 +131,7 @@ public abstract class VisualGraphComponentProvider<V extends VisualVertex,
//==================================================================================================
// Featurette Methods
//==================================================================================================
//==================================================================================================
/**
* Adds the satellite viewer functionality to this provider
@ -164,14 +168,14 @@ public abstract class VisualGraphComponentProvider<V extends VisualVertex,
Undo/redo for graph operations (delete; group/ungroup; move)
-rapid pressing will shortcut items
-undo/redo allows us to prune nodes
--how to maintain old nodes/edges? (FilteringVisualGraph)
-undo/redo allows us to prune nodes
--how to maintain old nodes/edges? (FilteringVisualGraph)
*/
//==================================================================================================
// Provider Methods
//==================================================================================================
//==================================================================================================
/**
* To be called at the end of this provider's lifecycle