#25 fix NPE on double-click in secondary thread
authorKevin Lamonte <kevin.lamonte@gmail.com>
Wed, 27 Dec 2017 23:41:34 +0000 (18:41 -0500)
committerKevin Lamonte <kevin.lamonte@gmail.com>
Wed, 27 Dec 2017 23:41:34 +0000 (18:41 -0500)
src/jexer/TApplication.java

index ee2e9de86664a04a238070b40637dff35a393176..34f1559007090b31eef65a4d79be9288ed54dec7 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);
+            }
         }
     }