Browse Source

Fixed crash when closing the solution while building.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2704 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
22eed44cab
  1. 12
      src/Main/Base/Project/Src/Project/BuildEngine.cs
  2. 5
      src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

12
src/Main/Base/Project/Src/Project/BuildEngine.cs

@ -106,8 +106,8 @@ namespace ICSharpCode.SharpDevelop.Project
{ {
EventHandler eh = null; EventHandler eh = null;
lock (lockObject) { lock (lockObject) {
if (isCancelAllowed) { if (isCancelAllowed && !isCancelled) {
ICSharpCode.Core.LoggingService.Debug(""); ICSharpCode.Core.LoggingService.Debug("Cancel build");
isCancelled = true; isCancelled = true;
eh = Cancelled; eh = Cancelled;
} }
@ -493,9 +493,11 @@ namespace ICSharpCode.SharpDevelop.Project
return; return;
buildIsDone = true; buildIsDone = true;
} }
foreach (BuildNode n in nodeDict.Values) { if (!buildIsCancelled) {
if (!n.buildFinished) { foreach (BuildNode n in nodeDict.Values) {
throw new Exception("All workers done, but a project did not finish building"); if (!n.buildFinished) {
throw new Exception("All workers done, but a project did not finish building");
}
} }
} }
string buildTime = " (" + (DateTime.Now - buildStart).ToString() + ")"; string buildTime = " (" + (DateTime.Now - buildStart).ToString() + ")";

5
src/Main/Base/Project/Src/Services/ProjectService/ProjectService.cs

@ -460,6 +460,11 @@ namespace ICSharpCode.SharpDevelop.Project
public static void CloseSolution() 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) { if (openSolution != null) {
CurrentProject = null; CurrentProject = null;
OnSolutionClosing(new SolutionEventArgs(openSolution)); OnSolutionClosing(new SolutionEventArgs(openSolution));

Loading…
Cancel
Save