From f43d97fbac0032a75eeaa23d641094182cd1d022 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 12 Dec 2011 17:05:39 +0100 Subject: [PATCH] correctly handle project opening cancellation (RUBY-9997) --- .../project/impl/ProjectManagerImpl.java | 21 +++++++++++++------ .../PlatformProjectOpenProcessor.java | 7 ++----- 2 files changed, 17 insertions(+), 11 deletions(-) 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 e1d29e5415f3..213c143323da 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 @@ -453,7 +453,7 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt public Project loadAndOpenProject(@NotNull final String filePath) throws IOException { - final Project project = convertAndLoadProject(filePath, null); + final Project project = convertAndLoadProject(filePath); if (project == null) { showWelcomeScreenIfNoProjectOpened(); return null; @@ -478,14 +478,17 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt } } } - + + /** + * Converts and loads the project at the specified path. + * + * @param filePath the path to open the project. + * @return the project, or null if the user has cancelled opening the project. + */ @Nullable - public Project convertAndLoadProject(String filePath, @Nullable Ref conversionResultRef) throws IOException { + public Project convertAndLoadProject(String filePath) throws IOException { final String fp = canonicalize(filePath); final ConversionResult conversionResult = ConversionService.getInstance().convert(fp); - if (conversionResultRef != null) { - conversionResultRef.set(conversionResult); - } if (conversionResult.openingIsCanceled()) { return null; } @@ -503,6 +506,12 @@ public class ProjectManagerImpl extends ProjectManagerEx implements NamedJDOMExt return project; } + /** + * Opens the project at the specified path. + * + * @param filePath the path to open the project. + * @return the project, or null if the user has cancelled opening the project. + */ @Nullable private Project loadProjectWithProgress(final @NotNull String filePath) throws IOException { diff --git a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java index 0d60ed6689a2..c0cc2f81e7cb 100644 --- a/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java +++ b/platform/platform-impl/src/com/intellij/platform/PlatformProjectOpenProcessor.java @@ -15,8 +15,6 @@ */ package com.intellij.platform; -import com.intellij.conversion.ConversionResult; - import com.intellij.ide.GeneralSettings; import com.intellij.ide.impl.ProjectUtil; import com.intellij.openapi.diagnostic.Logger; @@ -145,9 +143,8 @@ public class PlatformProjectOpenProcessor extends ProjectOpenProcessor { processor.refreshProjectFiles(projectDir); } - Ref conversionResultRef = new Ref(); - project = ((ProjectManagerImpl) projectManager).convertAndLoadProject(baseDir.getPath(), conversionResultRef); - if (conversionResultRef.get().openingIsCanceled()) { + project = ((ProjectManagerImpl) projectManager).convertAndLoadProject(baseDir.getPath()); + if (project == null) { return null; } runConfigurators = false;