changeset 6524:c5ebcc5268b4

RT-36256 Using showAndWait in the onFinished EventHandler of an Animation doesn't work Reviewed by: kcr
author Martin Sladecek <martin.sladecek@oracle.com>
date Thu, 20 Mar 2014 07:38:31 +0100
parents c58357d30622
children 492c42c21d9f
files modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java modules/graphics/src/main/java/javafx/stage/Stage.java
diffstat 2 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Wed Mar 19 19:49:59 2014 -0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java	Thu Mar 20 07:38:31 2014 +0100
@@ -218,6 +218,7 @@
     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());
@@ -472,6 +473,7 @@
                 return;
             }
             nextPulseRequested.set(false);
+            inPulse = true;
             if (animationRunnable != null) {
                 animationRunning.set(true);
                 animationRunnable.run();
@@ -481,6 +483,7 @@
             firePulse();
             if (collect) collector.renderAll();
         } finally {
+            inPulse = false;
             endPulseRunning();
             if (PULSE_LOGGING_ENABLED) {
                 PulseLogger.pulseEnd();
@@ -532,6 +535,10 @@
         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<>();
         }
--- a/modules/graphics/src/main/java/javafx/stage/Stage.java	Wed Mar 19 19:49:59 2014 -0400
+++ b/modules/graphics/src/main/java/javafx/stage/Stage.java	Thu Mar 20 07:38:31 2014 +0100
@@ -393,6 +393,8 @@
      *
      * @throws IllegalStateException if this method is called on a thread
      *     other than the JavaFX Application Thread.
+     * @throws java.lang.IllegalStateException if this method is called outside of
+     *     event handler. This includes animation callbacks, properties handlers and layout processing.
      * @throws IllegalStateException if this method is called on the
      *     primary stage.
      * @throws IllegalStateException if this stage is already showing.