kojix2 / LibUI

A portable GUI library for Ruby
MIT License
208 stars 10 forks source link

I get an error when I register two handlers #22

Closed PJZ9n closed 3 years ago

PJZ9n commented 3 years ago

Problem

Attempting both window_on_closing and window_on_content_size_changed will result in an error.

For example, if you do the following, it will work normally.

#UI.window_on_closing(WINDOW, closing)
UI.window_on_content_size_changed(WINDOW, content_size_changed)

Expected behavior

It is registered normally and works.

Error message

Traceback (most recent call last):
        4: from file.rb:16:in `<main>'
        3: fromlibui-0.0.8/lib/libui.rb:40:in `block (2 levels) in singleton class'
        2: from libui-0.0.8/lib/libui.rb:40:in `with_index'
        1: from libui-0.0.8/lib/libui.rb:40:in `map!'
libui-0.0.8/lib/libui.rb:51:in `block (3 levels) in singleton class': undefined method `<<' for #<Fiddle::Closure::BlockCaller> (NoMethodError)

Code to reproduce

require 'libui'

closing = proc do
  1
end
content_size_changed = proc do
  p "Content size is changed!"
end

UI = LibUI
UI.init

WINDOW = UI.new_window('Example', 300, 300, 0)
UI.window_on_closing(WINDOW, closing)
UI.window_on_content_size_changed(WINDOW, content_size_changed)

UI.control_show(WINDOW)

UI.main
UI.quit

Environments

Ruby version: ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x64-mingw32] Gem version: libui (0.0.8)

kojix2 commented 3 years ago

Thank you for reporting a serious bug.

This issue was already fixed in the commit https://github.com/kojix2/LibUI/commit/517584f7ddf00469d36b2caba71cf12a94dfb25b. However, I was not aware of the existence of the bug, so I did not release a new version.

kojix2 commented 3 years ago

Released v0.0.9

@PJZ9n Please let me know if you have any more problems!