From a65480a41eb61caf576b7a3bd35ea57d3df75e09 Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 16 Dec 2011 13:09:22 +0400 Subject: [PATCH] project already disposed --- .../openapi/vcs/changes/CallbackData.java | 40 ++++++++++++------- .../vcs/changes/UpdateRequestsQueue.java | 24 +++++------ 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CallbackData.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CallbackData.java index 89b8f4ceb682..8ad034cfee1b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CallbackData.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/CallbackData.java @@ -44,8 +44,8 @@ class CallbackData { return myWrapperStarter; } - public static CallbackData create(final Runnable afterUpdate, final String title, final ModalityState state, - final InvokeAfterUpdateMode mode, final Project project) { + public static CallbackData create(@NotNull final Runnable afterUpdate, final String title, final ModalityState state, + final InvokeAfterUpdateMode mode, @NotNull final Project project) { if (mode.isSilently()) { return new CallbackData(new Runnable() { public void run() { @@ -58,15 +58,22 @@ class CallbackData { ChangesViewManager.getInstance(project).scheduleRefresh(); } }); - } else { - ApplicationManager.getApplication().executeOnPooledThread(afterUpdate); + } + else { + ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { + @Override + public void run() { + if (!project.isDisposed()) afterUpdate.run(); + } + }); } } }, null); - } else { + } + else { if (mode.isSynchronous()) { final Waiter waiter = new Waiter(project, afterUpdate, state, - VcsBundle.message("change.list.manager.wait.lists.synchronization", title), mode.isCancellable()); + VcsBundle.message("change.list.manager.wait.lists.synchronization", title), mode.isCancellable()); return new CallbackData( new Runnable() { public void run() { @@ -74,13 +81,15 @@ class CallbackData { waiter.done(); } }, new Runnable() { - public void run() { - ProgressManager.getInstance().run(waiter); - } + public void run() { + ProgressManager.getInstance().run(waiter); } + } ); - } else { - final FictiveBackgroundable fictiveBackgroundable = new FictiveBackgroundable(project, afterUpdate, mode.isCancellable(), title, state); + } + else { + final FictiveBackgroundable fictiveBackgroundable = + new FictiveBackgroundable(project, afterUpdate, mode.isCancellable(), title, state); return new CallbackData( new Runnable() { public void run() { @@ -88,10 +97,11 @@ class CallbackData { fictiveBackgroundable.done(); } }, new Runnable() { - public void run() { - ProgressManager.getInstance().run(fictiveBackgroundable); - } - }); + public void run() { + ProgressManager.getInstance().run(fictiveBackgroundable); + } + } + ); } } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java index efcc5377532f..9d146c6626f8 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/UpdateRequestsQueue.java @@ -16,7 +16,6 @@ package com.intellij.openapi.vcs.changes; import com.intellij.ide.startup.impl.StartupManagerImpl; -import com.intellij.lifecycle.AtomicSectionsAware; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.diagnostic.Logger; @@ -27,7 +26,6 @@ import com.intellij.openapi.util.Getter; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.util.Consumer; import com.intellij.util.io.storage.HeavyProcessLatch; -import org.jetbrains.annotations.NonNls; import javax.swing.*; import java.util.ArrayList; @@ -43,7 +41,7 @@ import java.util.concurrent.TimeUnit; @SomeQueue public class UpdateRequestsQueue { private final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.changes.UpdateRequestsQueue"); - private final static String ourHeavyLatchOptimization = "vcs.local.changes.track.heavy.latch"; + private static final String ourHeavyLatchOptimization = "vcs.local.changes.track.heavy.latch"; private final Project myProject; private final ScheduledExecutorService myExecutor; private final Runnable myDelegate; @@ -57,9 +55,8 @@ public class UpdateRequestsQueue { private final ProjectLevelVcsManager myPlVcsManager; //private final ScheduledSlowlyClosingAlarm mySharedExecutor; private final StartupManager myStartupManager; - @NonNls public static final String LOCAL_CHANGES_UPDATE = "Local changes update"; private final boolean myTrackHeavyLatch; - private Getter myIsStoppedGetter; + private final Getter myIsStoppedGetter; public UpdateRequestsQueue(final Project project, final ScheduledExecutorService executor, final Runnable delegate) { myProject = project; @@ -165,15 +162,16 @@ public class UpdateRequestsQueue { LOG.debug("invokeAfterUpdate: stopped, invoke right now for project: " + myProject.getName()); SwingUtilities.invokeLater(new Runnable() { public void run() { - afterUpdate.run(); + if (!myProject.isDisposed()) { + afterUpdate.run(); + } } }); return; - } else { - // invoke progress if needed - if (data.getWrapperStarter() != null) { - data.getWrapperStarter().run(); - } + } + // invoke progress if needed + if (data.getWrapperStarter() != null) { + data.getWrapperStarter().run(); } LOG.debug("invokeAfterUpdate: exit for project: " + myProject.getName()); } @@ -186,7 +184,7 @@ public class UpdateRequestsQueue { // true = do not execute private boolean checkLifeCycle() { - return (! myStarted) || (! ((StartupManagerImpl) myStartupManager).startupActivityPassed()); + return !myStarted || !((StartupManagerImpl)myStartupManager).startupActivityPassed(); } private class MyRunnable implements Runnable { @@ -223,7 +221,7 @@ public class UpdateRequestsQueue { myWaitingUpdateCompletionQueue.removeAll(copy); } - if ((! myWaitingUpdateCompletionQueue.isEmpty()) && (! myRequestSubmitted)) { + if (! myWaitingUpdateCompletionQueue.isEmpty() && ! myRequestSubmitted) { LOG.error("No update task to handle request(s)"); } }