From 76240a5df90c9d1dab1dcbcd8a291a8408f59b4b Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 3 Dec 2009 20:58:38 +0300 Subject: [PATCH] stop iterating if project is disposed --- .../com/intellij/util/indexing/FileBasedIndex.java | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index f6f21036a1..59747f06f5 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -1815,18 +1815,25 @@ private boolean indexUnsavedDocument(final Document document, final ID req } public static void iterateIndexableFiles(final ContentIterator processor, Project project) { + if (project.isDisposed()) { + return; + } final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); - // iterate associated libraries - final Module[] modules = ModuleManager.getInstance(project).getModules(); // iterate project content projectFileIndex.iterateContent(processor); + if (project.isDisposed()) { + return; + } ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); Set visitedRoots = new com.intellij.util.containers.HashSet(); for (IndexedRootsProvider provider : Extensions.getExtensions(IndexedRootsProvider.EP_NAME)) { //important not to depend on project here, to support per-project background reindex // each client gives a project to FileBasedIndex + if (project.isDisposed()) { + return; + } final Set rootsToIndex = provider.getRootsToIndex(); for (String url : rootsToIndex) { final VirtualFile root = VirtualFileManager.getInstance().findFileByUrl(url); @@ -1835,7 +1842,15 @@ private boolean indexUnsavedDocument(final Document document, final ID req } } } - for (Module module : modules) { + + if (project.isDisposed()) { + return; + } + // iterate associated libraries + for (Module module : ModuleManager.getInstance(project).getModules()) { + if (module.isDisposed()) { + return; + } OrderEntry[] orderEntries = ModuleRootManager.getInstance(module).getOrderEntries(); for (OrderEntry orderEntry : orderEntries) { if (orderEntry instanceof LibraryOrderEntry || orderEntry instanceof JdkOrderEntry) { -- 2.11.4.GIT