-
Notifications
You must be signed in to change notification settings - Fork 75
Description
I get a segfault trying to define two handlers successively, even if I off() them after each use.
#!ruby
require 'ruby2d'
set width: 1000
def a
clear
evt = on :key_down do |event|
close if event.key == 'return'
end
show
off evt
end
a
a
puts 'end'What happens is that I start the script, the first a is called, I press Enter, the same method is called again, I press Enter again and so close is called, then the method ends, then the script ends... then Ruby segfaults:
I'm on macOS 10.15.7 with ruby 2.5.5, and ruby2d 0.9.5 which is the latest at the time I write this.
The reassignment of the event handler actually works fine (I've checked using a bit more code), the problem is that as soon as assign the key_down event the second time, and I call close and the script reaches its natural end (the "end" at the end is printed) then Ruby crashes with a segfault.
It's not a particularly big issue, since the script ends anyway, but it prevents me from exiting with a shell status of 0.
Is there an easy fix to this issue?
