Fixed a crash when trying to load files that do not exist

This commit is contained in:
biwa 2020-09-13 10:45:30 +02:00
parent 92c651bede
commit 3218218dcc

View file

@ -469,6 +469,12 @@ namespace CodeImp.DoomBuilder.Data
MemoryStream s = null; MemoryStream s = null;
string casecorrectfilename = GetCorrectCaseForFile(filename); string casecorrectfilename = GetCorrectCaseForFile(filename);
if(casecorrectfilename == null)
{
General.ErrorLogger.Add(ErrorType.Error, "Unable to load file " + filename + ": file doesn't exist");
return null;
}
try try
{ {
lock(this) lock(this)
@ -522,7 +528,14 @@ namespace CodeImp.DoomBuilder.Data
/// <returns></returns> /// <returns></returns>
protected override string GetCorrectCaseForFile(string filepathname) protected override string GetCorrectCaseForFile(string filepathname)
{ {
return files.GetFileInfo(filepathname).filepathname; try
{
return files.GetFileInfo(filepathname).filepathname;
}
catch(KeyNotFoundException e)
{
return null;
}
} }
#endregion #endregion