From 22eed44cabfd334cc794395c58d87c01339ee897 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sat, 29 Sep 2007 20:47:53 +0000 Subject: [PATCH] Fixed crash when closing the solution while building. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2704 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- src/Main/Base/Project/Src/Project/BuildEngine.cs | 12 +++++++----- .../Src/Services/ProjectService/ProjectService.cs | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Main/Base/Project/Src/Project/BuildEngine.cs b/src/Main/Base/Project/Src/Project/BuildEngine.cs index d6a9acc4b1..1b47cea484 100644 --- a/src/Main/Base/Project/Src/Project/BuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/BuildEngine.cs @@ -106,8 +106,8 @@ namespace ICSharpCode.SharpDevelop.Project { EventHandler eh = null; lock (lockObject) { - if (isCancelAllowed) { - ICSharpCode.Core.LoggingService.Debug(""); + if (isCancelAllowed && !isCancelled) { + ICSharpCode.Core.LoggingService.Debug("Cancel build"); isCancelled = true; eh = Cancelled; } @@ -493,9 +493,11 @@ namespace ICSharpCode.SharpDevelop.Project return; buildIsDone = true; } - foreach (BuildNode n in nodeDict.Values) { - if (!n.buildFinished) { - throw new Exception("All workers done, but a project did not finish building"); + if (!buildIsCancelled) { + foreach (BuildNode n in nodeDict.Values) { + if (!n.buildFinished) { + throw new Exception("All workers done, but a project did not finish building"); + } } } string buildTime = " (" + (DateTime.Now - buildStart).ToString() + ")"; diff --git a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs index 1920c346fe..a9840f0649 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs @@ -460,6 +460,11 @@ namespace ICSharpCode.SharpDevelop.Project public static void CloseSolution() { + // If a build is running, cancel it. + // If we would let a build run but unload the MSBuild projects, the next project.StartBuild call + // could cause an exception. + BuildEngine.CancelGuiBuild(); + if (openSolution != null) { CurrentProject = null; OnSolutionClosing(new SolutionEventArgs(openSolution));