project already disposed

This commit is contained in:
Alexey Kudravtsev
2011-12-16 13:18:13 +04:00
parent ecadd0ec2b
commit a65480a41e
2 changed files with 36 additions and 28 deletions
@@ -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);
}
}
);
}
}
}
@@ -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<Boolean> myIsStoppedGetter;
private final Getter<Boolean> 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)");
}
}