altosui: Display reader name (usually the device) when an I/O error occurs
authorKeith Packard <keithp@keithp.com>
Tue, 26 Apr 2011 05:28:40 +0000 (22:28 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 26 Apr 2011 05:28:40 +0000 (22:28 -0700)
Access the reader name directly from the reader object instead of a
local variable (which wasn't getting set anyways).

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

index 84abfae92966cc3c4c8cc6657fb3ebbf1f3e83f6..ce8d9159e7de420e9573806dec5d53217dd50539 100644 (file)
@@ -33,7 +33,6 @@ public class AltosDisplayThread extends Thread {
        Frame                   parent;
        IdleThread              idle_thread;
        AltosVoice              voice;
-       String                  name;
        AltosFlightReader       reader;
        int                     crc_errors;
        AltosFlightDisplay      display;
@@ -57,19 +56,18 @@ public class AltosDisplayThread extends Thread {
                SwingUtilities.invokeLater(r);
        }
 
-       void reading_error_internal(String name) {
+       void reading_error_internal() {
                JOptionPane.showMessageDialog(parent,
-                                             String.format("Error reading from \"%s\"", name),
+                                             String.format("Error reading from \"%s\"", reader.name),
                                              "Telemetry Read Error",
                                              JOptionPane.ERROR_MESSAGE);
        }
 
-       void reading_error_safely(String in_name) {
-               final String name = in_name;
+       void reading_error_safely() {
                Runnable r = new Runnable() {
                                public void run() {
                                        try {
-                                               reading_error_internal(name);
+                                               reading_error_internal();
                                        } catch (Exception ex) {
                                        }
                                }
@@ -258,7 +256,7 @@ public class AltosDisplayThread extends Thread {
                } catch (InterruptedException ee) {
                        interrupted = true;
                } catch (IOException ie) {
-                       reading_error_safely(name);
+                       reading_error_safely();
                } finally {
                        if (!interrupted)
                                idle_thread.report(true);