diff options
author | Keith Packard <keithp@keithp.com> | 2015-09-21 06:25:49 +0100 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-10-13 13:54:28 -0700 |
commit | 0f8272852b12cf7a349cd9fd07f17c55cdb335a1 (patch) | |
tree | 858256680cd0c0ec8c985eb501dba7d89ad99cc9 /altoslib | |
parent | a81d028dc62a0a624051fc3c9debb9687fda931e (diff) |
altoslib: Make sure .eeprom download file is flushed on exception
Flush and close the eeprom file even if an exception occurs to make
sure that contents of the file aren't lost.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosEepromDownload.java | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 5e035dbc..c4ddb0e7 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -147,7 +147,6 @@ public class AltosEepromDownload implements Runnable { /* Reset per-capture variables */ want_file = false; - eeprom_file = null; eeprom_pending = new LinkedList<String>(); /* Set serial number in the monitor dialog window */ @@ -185,10 +184,6 @@ public class AltosEepromDownload implements Runnable { block - log.start_block); } CheckFile(true); - if (eeprom_file != null) { - eeprom_file.flush(); - eeprom_file.close(); - } } public void run () { @@ -201,11 +196,16 @@ public class AltosEepromDownload implements Runnable { parse_exception = null; if (log.selected) { monitor.reset(); + eeprom_file = null; try { CaptureLog(log); } catch (ParseException e) { parse_exception = e; } + if (eeprom_file != null) { + eeprom_file.flush(); + eeprom_file.close(); + } } if (parse_exception != null) { failed = true; |