Fix BackgroundTaskQueue for default project. [Rev=irengrig]
authorKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Thu, 17 Mar 2011 15:36:14 +0000 (18:36 +0300)
committerKirill Likhodedov <kirill.likhodedov@jetbrains.com>
Fri, 1 Apr 2011 07:50:23 +0000 (11:50 +0400)
For default project don't kill the queue by "isOpen" condition.
Also changed code style a bit.

platform/platform-impl/src/com/intellij/openapi/progress/BackgroundTaskQueue.java

index d56ecf74a3106c9beda3b0c451babb1dd45ed522..7c50d43de7620e838132ecf1d4f3c7ab977fab8a 100644 (file)
@@ -52,13 +52,20 @@ public class BackgroundTaskQueue {
 
   public BackgroundTaskQueue(@Nullable final Project project, @NotNull String title, final Boolean forcedHeadlessMode) {
     final boolean headless = forcedHeadlessMode != null ? forcedHeadlessMode : ApplicationManager.getApplication().isHeadlessEnvironment();
-    myProcessor = new QueueProcessor<Pair<Task.Backgroundable, Getter<ProgressIndicator>>>(headless ?
-      new BackgroundableHeadlessRunner() : new BackgroundableUnderProgressRunner(title, project), true,
-      headless ? QueueProcessor.ThreadToUse.POOLED : QueueProcessor.ThreadToUse.AWT, new Condition<Object>() {
-        @Override
-        public boolean value(Object o) {
+
+    final QueueProcessor.ThreadToUse threadToUse = headless ? QueueProcessor.ThreadToUse.POOLED : QueueProcessor.ThreadToUse.AWT;
+    final PairConsumer<Pair<Task.Backgroundable, Getter<ProgressIndicator>>, Runnable> consumer
+      = headless ? new BackgroundableHeadlessRunner() : new BackgroundableUnderProgressRunner(title, project);
+
+    myProcessor = new QueueProcessor<Pair<Task.Backgroundable, Getter<ProgressIndicator>>>(consumer, true,
+                                                                                           threadToUse, new Condition<Object>() {
+        @Override public boolean value(Object o) {
           if (project == null) return ApplicationManager.getApplication().isDisposed();
-          return !ApplicationManager.getApplication().isUnitTestMode() && !project.isOpen() || project.isDisposed();
+          if (project.isDefault()) {
+            return project.isDisposed();
+          } else {
+            return !ApplicationManager.getApplication().isUnitTestMode() && !project.isOpen() || project.isDisposed();
+          }
         }
       });
   }