Skip to content

Commit

Permalink
SLI-1521 TreeUI should be accessed only from EDT
Browse files Browse the repository at this point in the history
  • Loading branch information
eray-felek-sonarsource committed Aug 29, 2024
1 parent 7e2e308 commit 08db5d6
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/main/java/org/sonarlint/intellij/ui/AbstractIssuesPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.intellij.openapi.actionSystem.ActionToolbar;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileEditor.OpenFileDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.SimpleToolWindowPanel;
Expand Down Expand Up @@ -188,13 +189,17 @@ private OccurenceNavigator.OccurenceInfo occurrence(Tree tree, @Nullable IssueNo
@Override
public boolean hasNextOccurence() {
// relies on the assumption that a TreeNodes will always be the last row in the table view of the tree
var isOldTree = tree.getSelectionPath() == null;
var path = isOldTree ? oldTree.getSelectionPath() : tree.getSelectionPath();
if (path == null) {
return false;
}

return isOldTree ? fetchNextOccurenceInfo(path, oldTree) : fetchNextOccurenceInfo(path, tree);
var result = new boolean[1];
ApplicationManager.getApplication().invokeAndWait(() -> {
var isOldTree = tree.getSelectionPath() == null;
var path = isOldTree ? oldTree.getSelectionPath() : tree.getSelectionPath();
if (path == null) {
result[0] = false;
} else {
result[0] = isOldTree ? fetchNextOccurenceInfo(path, oldTree) : fetchNextOccurenceInfo(path, tree);
}
});
return result[0];
}

private static boolean fetchNextOccurenceInfo(TreePath path, Tree tree) {
Expand Down

0 comments on commit 08db5d6

Please sign in to comment.