Skip to content
Permalink
Browse files
8262725: IGV: crash when removing all graphs in a group
Make IGV close graph views when their groups are either removed or emptied, and
avoid faulty graph view computation for empty groups.

Reviewed-by: chagedorn, rrich
  • Loading branch information
Roberto Castañeda Lozano committed Apr 20, 2021
1 parent 79798c6 commit 51366439b14b9f067b1c93e59394b84907bfe35a
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -206,6 +206,11 @@ public void changed(DiagramViewModel source) {
@Override
public void changed(Group source) {
assert source == group;
if (group.getGraphs().isEmpty()) {
// If the group has been emptied, all corresponding graph views
// will be closed, so do nothing.
return;
}
filterGraphs();
setSelectedNodes(selectedNodes);
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@

import com.sun.hotspot.igv.data.ChangedEvent;
import com.sun.hotspot.igv.data.ChangedListener;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.InputNode;
import com.sun.hotspot.igv.data.Properties;
import com.sun.hotspot.igv.data.Properties.PropertyMatcher;
@@ -225,6 +227,12 @@ public void changed(DiagramViewModel source) {
}
});

Group group = getDiagram().getGraph().getGroup();
group.getChangedEvent().addListener(g -> closeOnRemovedOrEmptyGroup());
if (group.getParent() instanceof GraphDocument) {
final GraphDocument doc = (GraphDocument) group.getParent();
doc.getChangedEvent().addListener(d -> closeOnRemovedOrEmptyGroup());
}

toolBar.add(NextDiagramAction.get(NextDiagramAction.class));
toolBar.add(PrevDiagramAction.get(PrevDiagramAction.class));
@@ -449,6 +457,14 @@ protected String preferredID() {
return PREFERRED_ID;
}

private void closeOnRemovedOrEmptyGroup() {
Group group = getDiagram().getGraph().getGroup();
if (!group.getParent().getElements().contains(group) ||
group.getGraphs().isEmpty()) {
close();
}
}

private ChangedListener<DiagramViewModel> diagramChangedListener = new ChangedListener<DiagramViewModel>() {

@Override

1 comment on commit 5136643

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 5136643 Apr 20, 2021

Please sign in to comment.