mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-10-01 10:16:41 -05:00
B/detect save null reference (#333)
* Fixed null reference exception in certain cases in save auto-loading * Fixed form close warning showing with no changes made since start * Fixed abort button in ErrorWindow * Simplified implementation
This commit is contained in:
@@ -181,7 +181,10 @@ public Main()
|
||||
if (path != null && File.Exists(path))
|
||||
openQuick(path, force: true);
|
||||
else
|
||||
{
|
||||
openSAV(SAV, null);
|
||||
SAV.Edited = false; // Prevents form close warning from showing until changes are made
|
||||
}
|
||||
}
|
||||
|
||||
// Splash Screen closes on its own.
|
||||
|
||||
@@ -18,7 +18,7 @@ public static DialogResult ShowErrorDialog(string friendlyMessage, Exception ex,
|
||||
var dialogResult = dialog.ShowDialog();
|
||||
if (dialogResult == DialogResult.Abort)
|
||||
{
|
||||
Application.Exit();
|
||||
Environment.Exit(1);
|
||||
}
|
||||
return dialogResult;
|
||||
}
|
||||
|
||||
@@ -544,7 +544,7 @@ public static string detectSaveFile()
|
||||
possiblePaths.AddRange(getSavesFromFolder(Path.Combine(pathCache), false));
|
||||
|
||||
// return newest save file path that is valid (oh man)
|
||||
return possiblePaths.OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(p => getVariantSAV(File.ReadAllBytes(p)).ChecksumsValid);
|
||||
return possiblePaths.OrderByDescending(f => new FileInfo(f).LastWriteTime).FirstOrDefault(p => getVariantSAV(File.ReadAllBytes(p))?.ChecksumsValid ?? false);
|
||||
}
|
||||
/// <summary>
|
||||
/// Retrieves the full path of the most recent file based on LastWriteTime.
|
||||
|
||||
Reference in New Issue
Block a user