changeset 5752:b6289f52ab84

RT-34350: [SWT] FXCanvas hangs for any example Summary: The fix was to run code right away in DND when on FX thread for SWT Reviewed-by: anthony
author snorthov
date Tue, 19 Nov 2013 09:51:06 -0500
parents 0d05f81de2be
children 7369a156078e
files modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedSceneDnD.java
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedSceneDnD.java	Tue Nov 19 18:41:25 2013 +0400
+++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/EmbeddedSceneDnD.java	Tue Nov 19 09:51:06 2013 -0500
@@ -96,7 +96,17 @@
      * dragOver() in SwingDnD is executed before dragEnter() is finished
      */
     <T> T executeOnFXThread(final Callable<T> r) {
-        assert !Platform.isFxApplicationThread();
+        
+        // When running under SWT, the main thread is the FX thread
+        // so execute the callable right away (return null on failure)
+        if (Platform.isFxApplicationThread()) {
+            try {
+                return r.call();
+            } catch (Exception z) {
+                // ignore
+            }
+            return null;
+        }
 
         final AtomicReference<T> result = new AtomicReference<>();
         final CountDownLatch l = new CountDownLatch(1);