1.1 --- a/src/Pure/General/swing_thread.scala Sat Jan 09 18:23:02 2010 +0100
1.2 +++ b/src/Pure/General/swing_thread.scala Sat Jan 09 23:22:24 2010 +0100
1.3 @@ -29,9 +29,14 @@
1.4 result.get
1.5 }
1.6
1.7 - def future[A](body: => A): Future[A] = Future.fork { now(body) }
1.8 + def future[A](body: => A): Future[A] =
1.9 + {
1.10 + if (SwingUtilities.isEventDispatchThread()) Future.value(body)
1.11 + else Future.fork { now(body) }
1.12 + }
1.13
1.14 - def later(body: => Unit) {
1.15 + def later(body: => Unit)
1.16 + {
1.17 if (SwingUtilities.isEventDispatchThread()) body
1.18 else SwingUtilities.invokeLater(new Runnable { def run = body })
1.19 }