summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-11-19 23:09:15 -0800
committerKeith Packard <keithp@keithp.com>2010-11-19 23:09:15 -0800
commit8c8dc3794c7b5fa5a5b43b1c461d6c8bb3ab425d (patch)
tree6b8c71711de2ca288f7a26344de6f96e53538889
parent594e80572821f1848db062d0cff18ca8bf0d90ce (diff)
altosui: When switching log files, don't terminate log thread
The log thread automatically switches output files when the incoming telemetry changes. Don't use 'close' for that as 'close' terminates the log thread as well as closing the file. Create a new 'close_log_file' function which just closes the file. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--ao-tools/altosui/AltosLog.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/ao-tools/altosui/AltosLog.java b/ao-tools/altosui/AltosLog.java
index 137147d5..11319768 100644
--- a/ao-tools/altosui/AltosLog.java
+++ b/ao-tools/altosui/AltosLog.java
@@ -36,15 +36,23 @@ class AltosLog implements Runnable {
FileWriter log_file;
Thread log_thread;
- void close() {
+ private void close_log_file() {
if (log_file != null) {
try {
log_file.close();
} catch (IOException io) {
}
+ log_file = null;
}
- if (log_thread != null)
+ }
+
+ void close() {
+ close_log_file();
+ if (log_thread != null) {
+ log_thread.interrupt();
+ log_thread = null;
log_thread.interrupt();
+ }
}
boolean open (AltosTelemetry telem) throws IOException {
@@ -74,7 +82,7 @@ class AltosLog implements Runnable {
try {
AltosTelemetry telem = new AltosTelemetry(line.line);
if (telem.serial != serial || telem.flight != flight || log_file == null) {
- close();
+ close_log_file();
serial = telem.serial;
flight = telem.flight;
open(telem);