modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java
Print this page
rev 8895 : RT-39689: Better docs and error checking if Printing or Dialogs called from Animation
@@ -192,11 +192,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 int inPulse = 0;
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;
@@ -498,21 +498,21 @@
if (!toolkitRunning.get()) {
return;
}
nextPulseRequested.set(false);
- inPulse = true;
+ inPulse++;
if (animationRunnable != null) {
animationRunning.set(true);
animationRunnable.run();
} else {
animationRunning.set(false);
}
firePulse();
if (collect) collector.renderAll();
} finally {
- inPulse = false;
+ inPulse--;
endPulseRunning();
if (PULSE_LOGGING_ENABLED) {
PulseLogger.pulseEnd();
}
}
@@ -553,17 +553,22 @@
stage.setRTL(rtl);
stage.init(systemMenu);
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");
}
if (eventLoopMap == null) {
eventLoopMap = new HashMap<>();