From 50b4ebc4ba962c4d9467e09ab4ea0181ddb26374 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Sun, 11 Sep 2016 12:52:28 -0700 Subject: [PATCH] Catch & Rethrow getFieldsfromPKM Initialization variable is captured, reset, then the pkm is loaded. If an exception is thrown, the initialization state is not restored. There's other capture-reset-restore cases but pkm loading is the only one exposed to bad input. Should prevent #261 from happening. fieldsInitialized is checked in a bunch of events. --- PKHeX/MainWindow/Main.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PKHeX/MainWindow/Main.cs b/PKHeX/MainWindow/Main.cs index a57a53091..333cf7d4d 100644 --- a/PKHeX/MainWindow/Main.cs +++ b/PKHeX/MainWindow/Main.cs @@ -1382,7 +1382,8 @@ public void populateFields(PKM pk, bool focus = true) Util.Alert("Converted File."); } - getFieldsfromPKM(); + try { getFieldsfromPKM(); } + catch { fieldsInitialized = oldInit; throw; } CB_EncounterType.Visible = Label_EncounterType.Visible = pkm.Gen4; fieldsInitialized = oldInit;