--- old/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java 2015-05-15 12:01:59.220967000 -0700 +++ new/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java 2015-05-15 12:01:58.440965900 -0700 @@ -194,7 +194,7 @@ private AtomicBoolean animationRunning = new AtomicBoolean(false); private AtomicBoolean nextPulseRequested = new AtomicBoolean(false); private AtomicBoolean pulseRunning = new AtomicBoolean(false); - private boolean inPulse = false; + private int inPulse = 0; private CountDownLatch launchLatch = new CountDownLatch(1); final int PULSE_INTERVAL = (int)(TimeUnit.SECONDS.toMillis(1L) / getRefreshRate()); @@ -500,7 +500,7 @@ return; } nextPulseRequested.set(false); - inPulse = true; + inPulse++; if (animationRunnable != null) { animationRunning.set(true); animationRunnable.run(); @@ -510,7 +510,7 @@ firePulse(); if (collect) collector.renderAll(); } finally { - inPulse = false; + inPulse--; endPulseRunning(); if (PULSE_LOGGING_ENABLED) { PulseLogger.pulseEnd(); @@ -555,13 +555,18 @@ return stage; } + @Override public boolean canStartNestedEventLoop() { + return inPulse == 0; + } + @Override public Object enterNestedEventLoop(Object key) { checkFxUserThread(); if (key == null) { throw new NullPointerException(); } - if (inPulse) { + + if (!canStartNestedEventLoop()) { throw new IllegalStateException("Nested event loops are allowed only while handling system events"); }