#31 fix synchronized error
[nikiroo-utils.git] / src / jexer / TApplication.java
index ee2e9de86664a04a238070b40637dff35a393176..9fa64d0703ae5d973453db0abb998661eb76fe20 100644 (file)
@@ -1125,8 +1125,14 @@ public class TApplication implements Runnable {
         }
 
         secondaryEventReceiver.handleEvent(event);
-        if (doubleClick != null) {
-            secondaryEventReceiver.handleEvent(doubleClick);
+        // Note that it is possible for secondaryEventReceiver to be null
+        // now, because its handleEvent() might have finished out on the
+        // secondary thread.  So put any extra processing inside a null
+        // check.
+        if (secondaryEventReceiver != null) {
+            if (doubleClick != null) {
+                secondaryEventReceiver.handleEvent(doubleClick);
+            }
         }
     }
 
@@ -1199,7 +1205,8 @@ public class TApplication implements Runnable {
                     keepTimers.add(timer);
                 }
             }
-            timers = keepTimers;
+            timers.clear();
+            timers.addAll(keepTimers);
         }
 
         // Call onIdle's