From 4873fe1a557f396b196e567a71ce2efe98746acf Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 9 Apr 2012 15:59:29 +0400 Subject: [PATCH] VCS: correct checks for whether the project is disposed when listening VFS in application-level listener + in dirty scope manager --- .../vcs/changes/VcsDirtyScopeVfsListener.java | 41 +++++++++++++------ .../openapi/vcs/changes/VcsGuess.java | 1 + 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeVfsListener.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeVfsListener.java index 44db698385fb..91969e3058fe 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeVfsListener.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeVfsListener.java @@ -95,7 +95,7 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL } } // and notify VCSDirtyScopeManager - dirtyFilesAndDirs.markDirty(); + markDirtyOnPooled(dirtyFilesAndDirs); } @Override @@ -126,12 +126,18 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL } } // and notify VCSDirtyScopeManager - ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { - @Override - public void run() { - dirtyFilesAndDirs.markDirty(); - } - }); + markDirtyOnPooled(dirtyFilesAndDirs); + } + + private void markDirtyOnPooled(final FileAndDirsCollector dirtyFilesAndDirs) { + if (! dirtyFilesAndDirs.isEmpty()) { + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + dirtyFilesAndDirs.markDirty(); + } + }); + } } @Nullable @@ -202,6 +208,10 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL manager.filePathsDirty(files, dirs); } } + + public boolean isEmpty() { + return map.isEmpty(); + } } /** @@ -213,13 +223,18 @@ public class VcsDirtyScopeVfsListener implements ApplicationComponent, BulkFileL private Collection getManagers(final VirtualFile file) { final Collection result = new HashSet(); if (file == null) { return result; } - final Collection projects = myProjectLocator.getProjectsForFile(file); - for (Project project : projects) { - final VcsDirtyScopeManager manager = VcsDirtyScopeManager.getInstance(project); - if (manager != null) { - result.add(manager); + ApplicationManager.getApplication().runReadAction(new Runnable() { + @Override + public void run() { + final Collection projects = myProjectLocator.getProjectsForFile(file); + for (Project project : projects) { + final VcsDirtyScopeManager manager = VcsDirtyScopeManager.getInstance(project); + if (manager != null) { + result.add(manager); + } + } } - } + }); return result; } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsGuess.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsGuess.java index 39086f31dd2f..eec77ea709e5 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsGuess.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsGuess.java @@ -75,6 +75,7 @@ public class VcsGuess { private Boolean isFileInIndex(@Nullable final FilePath filePath, final VirtualFile validParent) { return ApplicationManager.getApplication().runReadAction(new Computable() { public Boolean compute() { + if (myProject.isDisposed()) return false; final boolean inContent = myVcsManager.isFileInContent(validParent); if (inContent) return true; if (filePath != null) {