From 422fea9dfbbb85114623df5060fd45d6da5315d6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 13 Jan 2012 15:17:56 +0100 Subject: [PATCH] more forceful forced exit --- .../application/impl/ApplicationImpl.java | 17 ++++++++++------- .../project/impl/ProjectManagerImpl.java | 12 ++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index f6b736c31f7d..0743dafcb11e 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -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 canClose = new Ref(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; diff --git a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java index eb164b92e414..faf376e92bd1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/project/impl/ProjectManagerImpl.java @@ -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) {