Skip to content

Commit 8f9d927

Browse files
rtyleyandy1138
authored andcommitted
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
1 parent cbf1063 commit 8f9d927

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/main/scala/scala/swing/Publisher.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ trait Publisher extends Reactor {
4444
/**
4545
* Notify all registered reactions.
4646
*/
47-
def publish(e: Event) { for (l <- listeners) l(e) }
47+
def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) }
4848

4949
listenTo(this)
5050
}

0 commit comments

Comments
 (0)