altoslib: create logfiles preference object. check link in existing_data
authorKeith Packard <keithp@keithp.com>
Sun, 31 Aug 2014 05:11:28 +0000 (00:11 -0500)
committerKeith Packard <keithp@keithp.com>
Sun, 31 Aug 2014 05:11:28 +0000 (00:11 -0500)
The logfiles preference hash wasn't getting created, resulting in
crashes.

When there was no link, don't try to load existing data.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosPreferences.java
altoslib/AltosTelemetryReader.java

index 0e91e4f475d5673bd4a21ef667d5147d7a84ddda..af87b213ee575a9c0f7990cb1505cb5b9ecb521e 100644 (file)
@@ -178,6 +178,8 @@ public class AltosPreferences {
 
                telemetry_rates = new Hashtable<Integer,Integer>();
 
+               logfiles = new Hashtable<Integer,File>();
+
                voice = backend.getBoolean(voicePreference, true);
 
                callsign = backend.getString(callsignPreference,"N0CALL");
index 8803e19f74087b528fdc0281877d03bb85a00ec9..7539452d4ad9cf3cb609a48b58292b197e128911 100644 (file)
@@ -185,6 +185,9 @@ public class AltosTelemetryReader extends AltosFlightReader {
        }
 
        private static AltosFlightReader existing_data(AltosLink link) {
+               if (link == null)
+                       return null;
+
                File    file = AltosPreferences.logfile(link.serial);
                if (file != null) {
                        AltosStateIterable      iterable = AltosStateIterable.iterable(file);