From 5255f69c14d2c19f0e2f1f4ae8d9a106c92d3b8c Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Wed, 27 Dec 2017 18:41:34 -0500 Subject: [PATCH] #25 fix NPE on double-click in secondary thread --- src/jexer/TApplication.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index ee2e9de..34f1559 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -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); + } } } -- 2.27.0