Browse Source

Handle FileNotFoundException when file gets deleted/renamed while a background parse operation for that file is starting.

4.1
Daniel Grunwald 14 years ago
parent
commit
4f5fc89e8f
  1. 15
      src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

15
src/Main/Base/Project/Src/Services/ParserService/ParserService.cs

@ -406,7 +406,20 @@ namespace ICSharpCode.SharpDevelop @@ -406,7 +406,20 @@ namespace ICSharpCode.SharpDevelop
if (fileContent == null) {
// GetParseableFileContent must not be called inside any lock
// (otherwise we'd risk deadlocks because GetParseableFileContent must invoke on the main thread)
fileContent = GetParseableFileContent(fileName);
try {
fileContent = GetParseableFileContent(fileName);
} catch (System.Reflection.TargetInvocationException ex) {
// It is possible that the file gets deleted/becomes inaccessible while a background parse
// operation is enqueued, so we have to handle IO exceptions.
if (ex.InnerException is IOException || ex.InnerException is UnauthorizedAccessException)
return null;
else
throw;
} catch (IOException) {
return null;
} catch (UnauthorizedAccessException) {
return null;
}
}
ITextBufferVersion fileContentVersion = fileContent.Version;

Loading…
Cancel
Save