Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B/detect save null reference #333

Merged
merged 4 commits into from Oct 20, 2016
Merged

B/detect save null reference #333

merged 4 commits into from Oct 20, 2016

Conversation

evandixon
Copy link
Collaborator

Fixes the issue described here: https://projectpokemon.org/forums/showthread.php?50334-Newer-PKHex-Releases-won-t-run&p=221387&viewfull=1#post221387

Also fixes two other issues I found during testing: the abort button in the Error Window doing nothing, and the form close warning showing when the blank save is loaded.

@evandixon evandixon added the bug label Oct 19, 2016
@@ -544,7 +562,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 => isVariantSAVValid(File.ReadAllBytes(p)));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be:
.FirstOrDefault(p => getVariantSAV(File.ReadAllBytes(p))?.ChecksumsValid ?? false);
Removes the need for the extra method. Basically just null check the save in the linq instead of a separate method.

@kwsch kwsch merged commit adf7f55 into master Oct 20, 2016
@kwsch kwsch deleted the b/detect-save-null-reference branch October 20, 2016 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants