Skip to content

Commit 351a7f6

Browse files
committed
Make remove_callback more robust
If there is more than 1 callback on an event, there are issues when interrupting the event if the callback for the event target is not first in line. This change makes it so that you can find the callback associated with the target and interrupt it. Otherwise, i = nothing and deleteat! will fail.
1 parent c77022b commit 351a7f6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ macro callback(expr::Expr)
5959
end
6060

6161
function remove_callback(cb::Function, ev::AbstractEvent)
62-
i = indexin(ev.bev.callbacks, [cb])[1]
62+
i = findfirst(x -> x == cb, ev.bev.callbacks)
6363
i != 0 && deleteat!(ev.bev.callbacks, i)
6464
end
6565

0 commit comments

Comments
 (0)