X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fjexer%2FTApplication.java;h=b7c5f8ef51e5c63f30605d840d8dab0967f1b86b;hb=b2d49e0f15810a35a206e88c9bad11b053ed65fc;hp=d74d6c5aa98c964e7ee737e3ea960aab0b79eebb;hpb=b6faeac0d9c3e3ae3376ed28b54ec6ea6408ad7a;p=fanfix.git diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index d74d6c5..b7c5f8e 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -283,6 +283,10 @@ public class TApplication implements Runnable { * Wake the sleeping active event handler. */ private void wakeEventHandler() { + if (!started) { + return; + } + if (secondaryEventHandler != null) { synchronized (secondaryEventHandler) { secondaryEventHandler.notify(); @@ -426,6 +430,11 @@ public class TApplication implements Runnable { */ private List timers; + /** + * When true, the application has been started. + */ + private volatile boolean started = false; + /** * When true, exit the application. */ @@ -931,6 +940,8 @@ public class TApplication implements Runnable { primaryEventHandler = new WidgetEventHandler(this, true); (new Thread(primaryEventHandler)).start(); + started = true; + while (!quit) { synchronized (this) { boolean doWait = false; @@ -2383,6 +2394,24 @@ public class TApplication implements Runnable { } } + /** + * Post an event to process. + * + * @param event new event to add to the queue + */ + public final void postEvent(final TInputEvent event) { + synchronized (this) { + synchronized (fillEventQueue) { + fillEventQueue.add(event); + } + if (debugThreads) { + System.err.println(System.currentTimeMillis() + " " + + Thread.currentThread() + " postEvent() wake up main"); + } + this.notify(); + } + } + /** * Post an event to process and turn off the menu. *