From: Keith Packard Date: Sun, 5 Sep 2010 08:08:50 +0000 (-0700) Subject: altosui: When replay thread is interrupted, don't make final report X-Git-Tag: debian/0.7+79+g3d49d5f~8 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=6205547ec7191aab0259a8449520e966a96129e6 altosui: When replay thread is interrupted, don't make final report Normally, the replay process makes one final report after the file has been parsed. However, if the reading process is interrupted to display something else, this report is just annoying, so don't make it. Signed-off-by: Keith Packard --- diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 6a1814ff..49153766 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -384,11 +384,12 @@ public class AltosUI extends JFrame { AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { return null; } - void close() { } + void close(boolean interrupted) { } void update(AltosState state) throws InterruptedException { } public void run() { + boolean interrupted = false; String line; AltosState state = null; AltosState old_state = null; @@ -418,14 +419,18 @@ public class AltosUI extends JFrame { } } } catch (InterruptedException ee) { + interrupted = true; } catch (IOException ie) { JOptionPane.showMessageDialog(AltosUI.this, String.format("Error reading from \"%s\"", name), "Telemetry Read Error", JOptionPane.ERROR_MESSAGE); } finally { - close(); + close(interrupted); idle_thread.interrupt(); + try { + idle_thread.join(); + } catch (InterruptedException ie) {} } } @@ -446,7 +451,7 @@ public class AltosUI extends JFrame { return new AltosTelemetry(l.line); } - void close() { + void close(boolean interrupted) { serial.close(); serial.remove_monitor(telem); } @@ -530,8 +535,9 @@ public class AltosUI extends JFrame { return null; } - public void close () { - report(); + public void close (boolean interrupted) { + if (!interrupted) + report(); } public ReplayThread(AltosReader in_reader, String in_name) {