summaryrefslogtreecommitdiff
path: root/src/swing
diff options
context:
space:
mode:
authorRoberto Tyley <roberto.tyley@gmail.com>2013-11-29 14:26:56 +0000
committerRoberto Tyley <roberto.tyley@gmail.com>2013-12-09 18:37:41 +0000
commitc955cf4c2ee88d1f94cd45aeee238fc5344d2f18 (patch)
tree37f170a13255689d0a0a9294baddc1c52b078c82 /src/swing
parentdb19ddf36ef657e137e2b24fc70375f8476da327 (diff)
downloadscala-c955cf4c2ee88d1f94cd45aeee238fc5344d2f18.tar.gz
scala-c955cf4c2ee88d1f94cd45aeee238fc5344d2f18.tar.bz2
scala-c955cf4c2ee88d1f94cd45aeee238fc5344d2f18.zip
SI-8019 Make Publisher check PartialFunction is defined for Event
Reactions are PartialFunctions, so if events come through indiscriminately that the listener is not defined for, errors occur. Eg: -- Exception in thread "AWT-EventQueue-0" scala.MatchError: FocusGained(scala.swing wrapper scala.swing.TextField -- A Coursera thread with people affected by this issue: https://class.coursera.org/reactive-001/forum/thread?thread_id=1315
Diffstat (limited to 'src/swing')
-rw-r--r--src/swing/scala/swing/Publisher.scala2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala
index 96207de808..578ef71e09 100644
--- a/src/swing/scala/swing/Publisher.scala
+++ b/src/swing/scala/swing/Publisher.scala
@@ -44,7 +44,7 @@ trait Publisher extends Reactor {
/**
* Notify all registered reactions.
*/
- def publish(e: Event) { for (l <- listeners) l(e) }
+ def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) }
listenTo(this)
}