From d886db3afd8406c56d8b3bb70323ec9d60290376 Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 4 Oct 2012 14:18:34 +0400 Subject: [PATCH] GitRootDetector: remove read action access, because it may lead to live lock during project startup. Probably one of causes of IDEA-87656. Checking myProject.isDisposed() should be enough. If not, more checks can be added in the future. --- .../src/git4idea/roots/GitRootDetector.java | 55 ++++++++----------- 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java b/plugins/git4idea/src/git4idea/roots/GitRootDetector.java index f1283d6e89ee..1f0279fcc889 100644 --- a/plugins/git4idea/src/git4idea/roots/GitRootDetector.java +++ b/plugins/git4idea/src/git4idea/roots/GitRootDetector.java @@ -16,7 +16,6 @@ package git4idea.roots; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Computable; import com.intellij.openapi.vfs.VirtualFile; import git4idea.GitUtil; import git4idea.PlatformFacade; @@ -97,47 +96,37 @@ public class GitRootDetector { return roots; } - myPlatformFacade.runReadAction(new Computable() { - @Nullable @Override public Object compute() { - if (myProject.isDisposed() || !dir.isDirectory()) { - return null; - } - if (hasGitDir(dir)) { - roots.add(dir); - } - for (VirtualFile child : dir.getChildren()) { - roots.addAll(scanForRootsInsideDir(child, depth + 1)); - } - return null; - } - }); - + if (myProject.isDisposed() || !dir.isDirectory()) { + return roots; + } + if (hasGitDir(dir)) { + roots.add(dir); + } + for (VirtualFile child : dir.getChildren()) { + roots.addAll(scanForRootsInsideDir(child, depth + 1)); + } return roots; } @NotNull - private Set scanForRootsInsideDir(@NotNull VirtualFile projectDir) { - return scanForRootsInsideDir(projectDir, 0); + private Set scanForRootsInsideDir(@NotNull VirtualFile dir) { + return scanForRootsInsideDir(dir, 0); } @Nullable - private VirtualFile scanForSingleRootAboveDir(@NotNull final VirtualFile projectDir) { - return myPlatformFacade.runReadAction(new Computable() { - @Nullable @Override public VirtualFile compute() { - if (myProject.isDisposed()) { - return null; - } + private VirtualFile scanForSingleRootAboveDir(@NotNull final VirtualFile dir) { + if (myProject.isDisposed()) { + return null; + } - VirtualFile par = projectDir.getParent(); - while (par != null) { - if (hasGitDir(par)) { - return par; - } - par = par.getParent(); - } - return null; + VirtualFile par = dir.getParent(); + while (par != null) { + if (hasGitDir(par)) { + return par; } - }); + par = par.getParent(); + } + return null; } private static boolean hasGitDir(@NotNull VirtualFile dir) {