altosuilib: In display thread, set new state synchronously
[fw/altos] / altosuilib / AltosDisplayThread.java
index a773022bac1f0d39994b91f0c4de278e47453691..fac4ad722b079c0c96f42978f7c3e57e4bc60813 100644 (file)
@@ -219,12 +219,14 @@ public class AltosDisplayThread extends Thread {
                try {
                        for (;;) {
                                try {
-                                       state = reader.read();
-                                       if (state == null) {
+                                       AltosState new_state = reader.read();
+                                       if (new_state == null) {
+                                               state = null;
                                                listener_state.running = false;
                                                break;
                                        }
-                                       reader.update(state);
+                                       reader.update(new_state);
+                                       state = new_state;
                                        show_safely();
                                        told = tell();
                                        idle_thread.notice(told);