From 39e4a4f3710f63ff799d1916945eb95139bcd4f7 Mon Sep 17 00:00:00 2001 From: Dmitry Drobotov Date: Mon, 9 Dec 2024 13:41:26 +0100 Subject: [PATCH] IJPL-172840 Use Tree's suspend expand/collapse accessibility announcements API in the Usages tree This fixes a crash in Find Usages (IJPL-171433) (cherry picked from commit 70eef793231c7819b88453eb55c05a63df9142d3) IJ-CR-151182 GitOrigin-RevId: 3afbe9798ae200508739cc3e264af8fae187323f --- .../intellij/usages/impl/UsageViewImpl.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/platform/usageView-impl/src/com/intellij/usages/impl/UsageViewImpl.java b/platform/usageView-impl/src/com/intellij/usages/impl/UsageViewImpl.java index 4871f0a21269..73c77a090248 100644 --- a/platform/usageView-impl/src/com/intellij/usages/impl/UsageViewImpl.java +++ b/platform/usageView-impl/src/com/intellij/usages/impl/UsageViewImpl.java @@ -317,7 +317,7 @@ public class UsageViewImpl implements UsageViewEx { public int getId() { return myUniqueIdentifier; } - + @ApiStatus.Internal public JTree getTree() { return myTree; @@ -1138,11 +1138,21 @@ public class UsageViewImpl implements UsageViewEx { ThreadingAssertions.assertEventDispatchThread(); //always expand the last level group DefaultMutableTreeNode root = (DefaultMutableTreeNode)myTree.getModel().getRoot(); - for (int i = root.getChildCount() - 1; i >= 0; i--) { - DefaultMutableTreeNode child = (DefaultMutableTreeNode)root.getChildAt(i); - if (child instanceof GroupNode) { - TreePath treePath = new TreePath(child.getPath()); - myTree.expandPath(treePath); + try { + if (myTree instanceof Tree jbTree) { + jbTree.suspendExpandCollapseAccessibilityAnnouncements(); + } + for (int i = root.getChildCount() - 1; i >= 0; i--) { + DefaultMutableTreeNode child = (DefaultMutableTreeNode)root.getChildAt(i); + if (child instanceof GroupNode) { + TreePath treePath = new TreePath(child.getPath()); + myTree.expandPath(treePath); + } + } + } + finally { + if (myTree instanceof Tree jbTree) { + jbTree.resumeExpandCollapseAccessibilityAnnouncements(); } } myTree.getSelectionModel().clearSelection();