Must run the link open from the UI thread so that we can put up the
in-use dialog immdiately; otherwise the UI thread is blocked which
means the dialog never appears and the app appears to hang.
Signed-off-by: Keith Packard <keithp@keithp.com>
javax.swing.Timer timer;
JButton close;
ButtonGroup group;
javax.swing.Timer timer;
JButton close;
ButtonGroup group;
class IgniteHandler implements Runnable {
AltosIgnite ignite;
JFrame owner;
class IgniteHandler implements Runnable {
AltosIgnite ignite;
JFrame owner;
void send_exception(Exception e) {
final Exception f_e = e;
void send_exception(Exception e) {
final Exception f_e = e;
public void run () {
try {
public void run () {
try {
- AltosSerial serial = new AltosSerial(device);
- serial.set_frame(owner);
- ignite = new AltosIgnite(serial,
+ ignite = new AltosIgnite(link,
!device.matchProduct(Altos.product_altimeter));
} catch (Exception e) {
!device.matchProduct(Altos.product_altimeter));
} catch (Exception e) {
- public IgniteHandler(JFrame in_owner) {
+ public IgniteHandler(JFrame in_owner, AltosLink in_link) {
- send_command("quit");
- timer.stop();
+ if (opened) {
+ send_command("quit");
+ timer.stop();
+ }
setVisible(false);
dispose();
}
setVisible(false);
dispose();
}
command_queue = new LinkedBlockingQueue<String>();
reply_queue = new LinkedBlockingQueue<String>();
command_queue = new LinkedBlockingQueue<String>();
reply_queue = new LinkedBlockingQueue<String>();
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
device = AltosDeviceUIDialog.show(owner, Altos.product_any);
if (device != null) {
- IgniteHandler handler = new IgniteHandler(owner);
+ try {
+ AltosSerial serial = new AltosSerial(device);
+ serial.set_frame(owner);
+ IgniteHandler handler = new IgniteHandler(owner, serial);
Thread t = new Thread(handler);
t.start();
Thread t = new Thread(handler);
t.start();
+ } catch (Exception ex) {
+ ignite_exception(ex);
+ }