From 8c8dc3794c7b5fa5a5b43b1c461d6c8bb3ab425d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 19 Nov 2010 23:09:15 -0800 Subject: 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 --- ao-tools/altosui/AltosLog.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'ao-tools/altosui/AltosLog.java') 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); -- cgit v1.2.3 From 7920ed5c34b088f45ce4213b061ddd1ffe22cee8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 19 Nov 2010 23:18:51 -0800 Subject: altosui: calling thread.interrupt with null thread doesn't work well This was a left-over from debugging the previous patch. Signed-off-by: Keith Packard --- ao-tools/altosui/AltosLog.java | 1 - 1 file changed, 1 deletion(-) (limited to 'ao-tools/altosui/AltosLog.java') diff --git a/ao-tools/altosui/AltosLog.java b/ao-tools/altosui/AltosLog.java index 11319768..dd147d21 100644 --- a/ao-tools/altosui/AltosLog.java +++ b/ao-tools/altosui/AltosLog.java @@ -51,7 +51,6 @@ class AltosLog implements Runnable { if (log_thread != null) { log_thread.interrupt(); log_thread = null; - log_thread.interrupt(); } } -- cgit v1.2.3