summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-04-05 22:42:05 -0700
committerKeith Packard <keithp@keithp.com>2010-04-05 22:42:05 -0700
commitc099a67d9ea37e731e0eca318102560281ac240f (patch)
tree99aca25e09b49fea34501bd8f8d06dc8c6bc56ef
parentcc600a0389720bc7e435dbda8bec080ef19e0c58 (diff)
Interrupt running replay thread when starting another replay
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--ao-tools/altosui/AltosUI.java10
1 files 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,