Permalink
Browse files

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
  • Loading branch information...
1 parent db19ddf commit c955cf4c2ee88d1f94cd45aeee238fc5344d2f18 @rtyley rtyley committed Nov 29, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 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)
}

0 comments on commit c955cf4

Please sign in to comment.