more robust treatment of SwingUtilities.isEventDispatchThread;
authorwenzelm
Wed, 28 Jan 2009 11:36:45 +0100
changeset 29649 8b0c1397868e
parent 29648 ead544f3d6a1
child 29658 f2584b0c76b5
more robust treatment of SwingUtilities.isEventDispatchThread;
src/Pure/General/swing.scala
--- a/src/Pure/General/swing.scala	Wed Jan 28 10:43:31 2009 +0100
+++ b/src/Pure/General/swing.scala	Wed Jan 28 11:36:45 2009 +0100
@@ -10,9 +10,13 @@
 
 object Swing
 {
-  def now(body: => Unit) =
-    SwingUtilities.invokeAndWait(new Runnable { def run = body })
+  def now(body: => Unit) {
+    if (SwingUtilities.isEventDispatchThread) body
+    else SwingUtilities.invokeAndWait(new Runnable { def run = body })
+  }
 
-  def later(body: => Unit) =
-    SwingUtilities.invokeLater(new Runnable { def run = body })
+  def later(body: => Unit) {
+    if (SwingUtilities.isEventDispatchThread) body
+    else SwingUtilities.invokeLater(new Runnable { def run = body })
+  }
 }