From 0dafd5ef26e9ea5ce50d0436a5169ae6da64edb3 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Tue, 31 Jan 2012 21:15:18 +0400 Subject: [PATCH] Check for the case the project doesn't exist after reload. --- main/Load.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 main/Load.scala diff --git a/main/Load.scala b/main/Load.scala old mode 100644 new mode 100755 index 7f7bc5f69..7c5c92b94 --- a/main/Load.scala +++ b/main/Load.scala @@ -534,17 +534,23 @@ object Load } def initialSession(structure: BuildStructure, rootEval: () => Eval, s: State): SessionSettings = { - val current = s get Keys.sessionSettings map (_.currentProject) - new SessionSettings(structure.root, projectMap(structure.units, current), structure.settings, Map.empty, Nil, rootEval) + val current = s get Keys.sessionSettings map (_.currentProject) getOrElse Map.empty + new SessionSettings(structure.root, projectMap(structure, current), structure.settings, Map.empty, Nil, rootEval) } def initialSession(structure: BuildStructure, rootEval: () => Eval): SessionSettings = - new SessionSettings(structure.root, projectMap(structure.units, None), structure.settings, Map.empty, Nil, rootEval) + new SessionSettings(structure.root, projectMap(structure, Map.empty), structure.settings, Map.empty, Nil, rootEval) - def projectMap(units: Map[URI, LoadedBuildUnit], current: Option[Map[URI, String]]): Map[URI, String] = + def projectMap(structure: BuildStructure, current: Map[URI, String]): Map[URI, String] = { + val units = structure.units val getRoot = getRootProject(units) - units.keys.map(uri => (uri, current.flatMap(_ get uri) getOrElse getRoot(uri))).toMap + def project(uri: URI) = { + current get uri map { + p => if (structure allProjects uri map (_.id) contains p) p else getRoot(uri) + } getOrElse getRoot(uri) + } + units.keys.map(uri => (uri, project(uri))).toMap } def defaultEvalOptions: Seq[String] = Nil