altosuilib: Don't crash when flashing an unknown device
authorKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 17:22:02 +0000 (10:22 -0700)
committerKeith Packard <keithp@keithp.com>
Tue, 16 Jul 2019 17:22:02 +0000 (10:22 -0700)
An unknown device will not have a config; check for that before
showing radio calibration dialogs.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosFlashUI.java
altosuilib/AltosRomconfigUI.java

index ffb39b8c2aae4e4e7b2035a9e780355114808bf8..37ab96614af52f73d4ab116aa9c39f9d457f480e 100644 (file)
@@ -319,7 +319,7 @@ public class AltosFlashUI
                                return false;
                }
 
                                return false;
                }
 
-               if (existing_config.radio_calibration_broken) {
+               if (existing_config != null && existing_config.radio_calibration_broken) {
                        int ret = JOptionPane.showConfirmDialog(this,
                                                                String.format("Radio calibration value %d may be incorrect\nFlash anyways?",
                                                                              existing_config.radio_calibration),
                        int ret = JOptionPane.showConfirmDialog(this,
                                                                String.format("Radio calibration value %d may be incorrect\nFlash anyways?",
                                                                              existing_config.radio_calibration),
index fd670d4ec9df439081ee7533662989f9e2223083..f8dcc3e1fe9ba83e8f21ca819b5673407a7c0d68 100644 (file)
@@ -76,7 +76,7 @@ public class AltosRomconfigUI
 
                y++;
 
 
                y++;
 
-               if (AltosLib.has_radio(config.usb_id.pid)) {
+               if (config == null || AltosLib.has_radio(config.usb_id.pid)) {
                        /* Radio calibration value */
                        c = new GridBagConstraints();
                        c.gridx = 0; c.gridy = y;
                        /* Radio calibration value */
                        c = new GridBagConstraints();
                        c.gridx = 0; c.gridy = y;