Skip to content

[Possible bug or strange behaviour] On 2nd run the libui window is black #45

@rubyFeedback

Description

@rubyFeedback

Hey there kojix2,

I may have found a bug or at the least a weird behaviour.

First let me show the image - it shows a black window:

https://i.imgur.com/Sng4FNl.png

Next, here is how you can reproduce the behaviour:

First I took the code you showcase in the examples. I will copy/paste it next,
the only change I made was adding "class Button" so I can run this via
"Button.new":

    require 'libui'

    UI = LibUI

    UI.init

    class Button

      def initialize
        main_window = UI.new_window('hello world', 300, 200, 1)
        button = UI.new_button('Button')
        UI.button_on_clicked(button) do
          UI.msg_box(main_window, 'Information', 'You clicked the button')
        end
        UI.window_on_closing(main_window) do
          puts 'Bye Bye'
          UI.control_destroy(main_window)
          UI.quit
          0
        end
        UI.window_set_child(main_window, button)
        UI.control_show(main_window)
        UI.main
        UI.quit
      end

    end

Next, start irb. Do a:

require './button.rb'

or require_relative.

Then do:

Button.new

This is now important! On the first run it works fine. No error.

But!

After you close the window, and do:

Button.new

again, then this black window shows up. It looks to me as if it is
re-using some old data perhaps? Otherwise I would not know
why the second time it is run is different to the first run.

How did I discover this behaviour?

In one of my projects I use libui. I start it via a REPL, similar
to irb. First run is fine but second run always has this black
window. Perhaps I did something wrong, but the behaviour
by libui is quite strange - for instance, via ruby-gtk3 it works
just as expected, I always get the same widget when I run
it without any black window suddenly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions