diff options
author | Keith Packard <keithp@keithp.com> | 2013-12-18 01:14:11 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2013-12-18 01:14:11 -0800 |
commit | e26306c9350ef1d107d4257ef1c09d15165c9154 (patch) | |
tree | d7983c6a04c54b3307d6fc2699dad4fa21d8bde0 /altosui/AltosIdleMonitorUI.java | |
parent | 18852efa108ba6e6e69dfd5076d4f4c01f62b4ef (diff) |
altoslib: Pass InterruptedException up the stack instead of hiding it
When interrupting a thread that is talking to a serial device, it's
important not to have that thread discard the InterruptedException so
that it will actually terminate. This patch removes a bunch of places
that were discarding InterruptedExceptions and lets higher level code
see them so that they can exit cleanly.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosui/AltosIdleMonitorUI.java')
-rw-r--r-- | altosui/AltosIdleMonitorUI.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index f4e16243..6da920e2 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -23,6 +23,7 @@ import javax.swing.*; import javax.swing.event.*; import java.io.*; import java.util.concurrent.*; +import java.util.Arrays; import org.altusmetrum.altoslib_2.*; import org.altusmetrum.altosuilib_1.*; @@ -38,7 +39,10 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl void stop_display() { if (thread != null) { - thread.abort(); + try { + thread.abort(); + } catch (InterruptedException ie) { + } } thread = null; } @@ -191,7 +195,13 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - disconnect(); + System.out.printf("Closing idle monitor window\n"); + try { + disconnect(); + } catch (Exception ex) { + System.out.println(Arrays.toString(ex.getStackTrace())); + } + System.out.printf("hiding\n"); setVisible(false); dispose(); AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this); |