more forceful forced exit

This commit is contained in:
Dmitry Jemerov
2012-01-13 15:17:56 +01:00
parent 7db04f5db3
commit 422fea9dfb
2 changed files with 16 additions and 13 deletions
@@ -19,7 +19,6 @@ import com.intellij.CommonBundle;
import com.intellij.diagnostic.PerformanceWatcher;
import com.intellij.diagnostic.PluginException;
import com.intellij.ide.*;
import com.intellij.ide.impl.ProjectUtil;
import com.intellij.ide.plugins.IdeaPluginDescriptor;
import com.intellij.ide.plugins.PluginManager;
import com.intellij.idea.StartupUtil;
@@ -47,6 +46,7 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ex.ProjectEx;
import com.intellij.openapi.project.ex.ProjectManagerEx;
import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.*;
@@ -56,7 +56,10 @@ import com.intellij.openapi.wm.ex.ProgressIndicatorEx;
import com.intellij.openapi.wm.impl.IdeFrameImpl;
import com.intellij.psi.PsiLock;
import com.intellij.ui.Splash;
import com.intellij.util.*;
import com.intellij.util.Consumer;
import com.intellij.util.EventDispatcher;
import com.intellij.util.ReflectionCache;
import com.intellij.util.Restarter;
import com.intellij.util.concurrency.ReentrantWriterPreferenceReadWriteLock;
import com.intellij.util.containers.Stack;
import com.intellij.util.io.storage.HeavyProcessLatch;
@@ -290,7 +293,7 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
saveAll();
}
finally {
disposeSelf();
disposeSelf(true);
}
}
});
@@ -298,14 +301,14 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
});
}
private boolean disposeSelf() {
private boolean disposeSelf(final boolean checkCanCloseProject) {
final CommandProcessor commandProcessor = CommandProcessor.getInstance();
final Ref<Boolean> canClose = new Ref<Boolean>(Boolean.TRUE);
for (final Project project : ProjectManagerEx.getInstanceEx().getOpenProjects()) {
try {
commandProcessor.executeCommand(project, new Runnable() {
public void run() {
canClose.set(ProjectUtil.closeAndDispose(project));
canClose.set(((ProjectManagerImpl)ProjectManagerEx.getInstanceEx()).closeProject(project, true, true, checkCanCloseProject));
}
}, ApplicationBundle.message("command.exit"), null);
}
@@ -759,12 +762,12 @@ public class ApplicationImpl extends ComponentManagerImpl implements Application
saveSettings();
if (!canExit() && allowListenersToCancel) {
if (allowListenersToCancel && !canExit()) {
myExitCode = 0;
return;
}
final boolean success = disposeSelf();
final boolean success = disposeSelf(allowListenersToCancel);
if (!success || isUnitTestMode()) {
myExitCode = 0;
return;
@@ -446,7 +446,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
}, ProjectBundle.message("project.load.progress"), true, project);
if (!ok) {
closeProject(project, false, false);
closeProject(project, false, false, true);
notifyProjectOpenFailed();
return false;
}
@@ -957,15 +957,15 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
@Override
public boolean closeProject(@NotNull final Project project) {
return closeProject(project, true, false);
return closeProject(project, true, false, true);
}
private boolean closeProject(final Project project, final boolean save, final boolean dispose) {
public boolean closeProject(final Project project, final boolean save, final boolean dispose, boolean checkCanClose) {
if (ApplicationManager.getApplication().isUnitTestMode() && project.toString().contains("lighttemp")) {
throw new AssertionError("must not close light project");
}
if (!isProjectOpened(project)) return true;
if (!canClose(project)) return false;
if (checkCanClose && !canClose(project)) return false;
final ShutDownTracker shutDownTracker = ShutDownTracker.getInstance();
shutDownTracker.registerStopperThread(Thread.currentThread());
try {
@@ -974,7 +974,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
project.save();
}
if (!ensureCouldCloseIfUnableToSave(project)) {
if (checkCanClose && !ensureCouldCloseIfUnableToSave(project)) {
return false;
}
@@ -1006,7 +1006,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt
@Override
public boolean closeAndDispose(@NotNull final Project project) {
return closeProject(project, true, true);
return closeProject(project, true, true, true);
}
private void fireProjectClosing(Project project) {