From c099a67d9ea37e731e0eca318102560281ac240f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 5 Apr 2010 22:42:05 -0700 Subject: [PATCH] Interrupt running replay thread when starting another replay Signed-off-by: Keith Packard --- ao-tools/altosui/AltosUI.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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, -- 2.30.2