Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8262725: IGV: crash when removing all graphs in a group #3540

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
@@ -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