From: Keith Packard Date: Tue, 6 Apr 2010 05:42:05 +0000 (-0700) Subject: Interrupt running replay thread when starting another replay X-Git-Tag: debian/0.6+163+g01e524f~10 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=c099a67d9ea37e731e0eca318102560281ac240f;ds=sidebyside Interrupt running replay thread when starting another replay Signed-off-by: Keith Packard --- diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java index 54016ac5..b2305a21 100644 --- a/ao-tools/altosui/AltosUI.java +++ b/ao-tools/altosui/AltosUI.java @@ -481,7 +481,9 @@ public class AltosUI extends JFrame { try { if (state.state > AltosTelemetry.ao_flight_pad) Thread.sleep((int) (state.time_change * 1000)); - } catch (InterruptedException e) {} + } catch (InterruptedException e) { + break; + } } catch (ParseException pp) { JOptionPane.showMessageDialog(AltosUI.this, line, @@ -503,6 +505,7 @@ public class AltosUI extends JFrame { } } + ReplayThread replay_thread; /* * Replay a flight from telemetry data */ @@ -522,7 +525,10 @@ public class AltosUI extends JFrame { try { FileInputStream replay = new FileInputStream(file); ReplayThread thread = new ReplayThread(replay, filename); - thread.start(); + if (thread != null && replay_thread != null && replay_thread.isAlive()) + replay_thread.interrupt(); + replay_thread = thread; + replay_thread.start(); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(AltosUI.this, filename,