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.
This commit is contained in:
Kaphotics
2016-09-11 12:52:28 -07:00
parent f7afb88052
commit 50b4ebc4ba

View File

@@ -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;