altosui: Display exception messages from swing thread
authorKeith Packard <keithp@keithp.com>
Tue, 29 Mar 2011 16:38:23 +0000 (09:38 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 29 Mar 2011 16:38:23 +0000 (09:38 -0700)
Flight log management exceptions were getting displayed from the log
serial I/O thread instead of the swing thread. That's a bad plan.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosui/AltosEepromManage.java

index 5fb70a8413cba0e1e5b9be39f4421b46cc3467a8..b46364dbaacdd7efc8c6a13703407f8433ed9405 100644 (file)
@@ -168,17 +168,23 @@ public class AltosEepromManage implements ActionListener {
                AltosEepromManage       manage;
 
                public void run () {
+                       Runnable r;
                        try {
                                flights = new AltosEepromList(serial_line, remote);
-                               Runnable r = new Runnable() {
+                               r = new Runnable() {
                                                public void run() {
-                                                       manage.got_flights(flights);
+                                                       got_flights(flights);
                                                }
                                        };
-                               SwingUtilities.invokeLater(r);
                        } catch (Exception e) {
-                               manage.got_exception(e);
+                               final Exception f_e = e;
+                               r = new Runnable() {
+                                               public void run() {
+                                                       got_exception(f_e);
+                                               }
+                                       };
                        }
+                       SwingUtilities.invokeLater(r);
                }
 
                public EepromGetList(AltosEepromManage in_manage) {