Browse Source

Fix SD-1767 - NullReferenceException when closing a solution while "Loading References..." is active.

4.0
Daniel Grunwald 14 years ago
parent
commit
1aafa02c4c
  1. 3
      src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs
  2. 11
      src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

3
src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs

@ -407,6 +407,9 @@ namespace ICSharpCode.SharpDevelop.Project @@ -407,6 +407,9 @@ namespace ICSharpCode.SharpDevelop.Project
try {
System.Threading.Monitor.Enter(this.SyncRoot, ref lockTaken);
if (projectFile == null)
throw new ObjectDisposedException("MSBuildBasedProject");
if (configuration == null)
configuration = this.ActiveConfiguration;
if (platform == null)

11
src/Main/Base/Project/Src/Services/ParserService/ParseProjectContent.cs

@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop @@ -66,7 +66,7 @@ namespace ICSharpCode.SharpDevelop
if (reference != null) {
// TODO: Translate me
// progressMonitor.TaskName = "Loading " + reference.ShortName + "...";
AddReference(reference, false);
AddReference(reference, false, progressMonitor.CancellationToken);
}
}
}
@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop @@ -109,7 +109,7 @@ namespace ICSharpCode.SharpDevelop
}
}
void AddReference(ReferenceProjectItem reference, bool updateInterDependencies)
void AddReference(ReferenceProjectItem reference, bool updateInterDependencies, CancellationToken cancellationToken)
{
try {
AddReferencedContent(AssemblyParserService.GetProjectContentForReference(reference));
@ -122,6 +122,13 @@ namespace ICSharpCode.SharpDevelop @@ -122,6 +122,13 @@ namespace ICSharpCode.SharpDevelop
// If the user removes the reference and then re-adds it, there might be other references
// in the project depending on it, so we do the refresh after the old reference was added.
AssemblyParserService.RefreshProjectContentForReference(reference);
} catch (OperationCanceledException) {
throw;
} catch (ObjectDisposedException e) {
// ObjectDisposedException can happen if project gets disposed while LoadSolutionProjectsThread is running.
// We will ignore the ObjectDisposedException and throw OperationCanceledException instead.
cancellationToken.ThrowIfCancellationRequested();
MessageService.ShowException(e);
} catch (Exception e) {
MessageService.ShowException(e);
}

Loading…
Cancel
Save