modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java

Print this page

        

@@ -216,10 +216,11 @@
 
     private AtomicBoolean           toolkitRunning = new AtomicBoolean(false);
     private AtomicBoolean           animationRunning = new AtomicBoolean(false);
     private AtomicBoolean           nextPulseRequested = new AtomicBoolean(false);
     private AtomicBoolean           pulseRunning = new AtomicBoolean(false);
+    private boolean                 inPulse = false;
     private CountDownLatch          launchLatch = new CountDownLatch(1);
 
     final int                       PULSE_INTERVAL = (int)(TimeUnit.SECONDS.toMillis(1L) / getRefreshRate());
     final int                       FULLSPEED_INTERVAL = 1;     // ms
     boolean                         nativeSystemVsync = false;

@@ -470,19 +471,21 @@
 
             if (!toolkitRunning.get()) {
                 return;
             }
             nextPulseRequested.set(false);
+            inPulse = true;
             if (animationRunnable != null) {
                 animationRunning.set(true);
                 animationRunnable.run();
             } else {
                 animationRunning.set(false);
             }
             firePulse();
             if (collect) collector.renderAll();
         } finally {
+            inPulse = false;
             endPulseRunning();
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.pulseEnd();
             }
         }

@@ -530,10 +533,14 @@
         checkFxUserThread();
 
         if (key == null) {
             throw new NullPointerException();
         }
+        if (inPulse) {
+            throw new IllegalStateException("Nested event loops are allowed only while handling system events");
+        }
+
         if (eventLoopMap == null) {
             eventLoopMap = new HashMap<>();
         }
         if (eventLoopMap.containsKey(key)) {
             throw new IllegalArgumentException(