Skip to content

Commit

Permalink
Fix NPE when opening quick type hierarchy twice #2002
Browse files Browse the repository at this point in the history
Fixes #2002
  • Loading branch information
fedejeanne committed Feb 10, 2025
1 parent cb33fee commit 25ad338
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,23 @@ protected TreeViewer createTreeViewer(Composite parent, int style) {

@Override
protected void inputChanged(Object input, Object oldInput) {
visited= new HashSet<>();
super.inputChanged(input, oldInput);
visited= null;
runWithVisited(() -> super.inputChanged(input, oldInput));
}


@Override
public void expandToLevel(Object elementOrTreePath, int level, boolean disableRedraw) {
runWithVisited(
() -> super.expandToLevel(elementOrTreePath, level, disableRedraw));
}

private void runWithVisited(Runnable r) {
try {
visited= new HashSet<>();
r.run();
} finally {
visited= null;
}
}

@Override
Expand All @@ -156,7 +170,7 @@ private boolean shouldExpand(Widget widget) {
return false;
}
Object data= widget.getData();
return data == null || visited.add(data);
return data == null || visited == null || visited.add(data);
}
};
treeViewer.addFilter(new ViewerFilter() {
Expand Down

0 comments on commit 25ad338

Please sign in to comment.