telegps: Don't re-add frequency menu when already present.
authorKeith Packard <keithp@keithp.com>
Thu, 12 Jun 2014 21:32:15 +0000 (14:32 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 12 Jun 2014 21:32:15 +0000 (14:32 -0700)
If the receiver disappears, we'll stop tracking, but won't pull the
frequency menu down. Doing that would take a bit of work, and it
doesn't seem worth the effort. As a kludge-around, avoid re-creating
the frequency menu if it's already displayed when we connect to
another device.

Signed-off-by: Keith Packard <keithp@keithp.com>
telegps/TeleGPS.java

index 2503d53..9aaa80c 100644 (file)
@@ -323,6 +323,9 @@ public class TeleGPS
 
        void add_frequency_menu(int serial, final AltosFlightReader reader) {
                // Channel menu
+               if (frequencies != null)
+                       return;
+
                frequencies = new AltosFreqList(AltosUIPreferences.frequency(serial));
                frequencies.set_product("Monitor");
                frequencies.set_serial(serial);
@@ -343,6 +346,7 @@ public class TeleGPS
        void remove_frequency_menu() {
                if (frequencies != null) {
                        menu_bar.remove(frequencies);
+                       menu_bar.repaint();
                        frequencies = null;
                }
        }