# HG changeset patch # User Peter Hofer # Date 1320072913 -3600 # Node ID e4175b8b85d3652d162fe50ee846d3eca170ad48 # Parent 9f38ef8e075f08e1ffc182411f3624c5ef485c28 IdealGraphVisualizer: work around a Swing/NetBeans tree UI problem that occurs when mouse events are handled while the tree model is changing, e.g. when using IGV while it still receives graphs from a compiler. BasicTreeUI attempts to get the boundaries for the node associated with the location on screen, but fails and tries to access a null Rectangle, causing a user-visible NullPointerException. By implementing equals() for GraphNode, nodes for graphs that are already in the tree are not removed and re-added when updating groups, and the exception can no longer be reproduced. This potentially also resolves some redraw issues. diff -r 9f38ef8e075f -r e4175b8b85d3 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Mon Oct 31 12:24:43 2011 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Mon Oct 31 15:55:13 2011 +0100 @@ -27,7 +27,6 @@ import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie; import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie; import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie; -import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.services.GraphViewer; @@ -35,7 +34,6 @@ import java.awt.Image; import javax.swing.Action; import org.openide.actions.OpenAction; -import org.openide.cookies.OpenCookie; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Sheet; @@ -50,7 +48,7 @@ */ public class GraphNode extends AbstractNode { - private InputGraph graph; + private final InputGraph graph; /** Creates a new instance of GraphNode */ public GraphNode(InputGraph graph) { @@ -107,4 +105,20 @@ public Action getPreferredAction() { return (Action) OpenAction.findObject(OpenAction.class, true); } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof GraphNode) { + return (graph == ((GraphNode) obj).graph); + } + return false; + } + + @Override + public int hashCode() { + return graph.hashCode(); + } }