FoX: FXMessageBox and threads

Hello all,

I have a FoX application written using threads, and I came across a strange problem -
when a FXMessageBox is created from a thread other than the one FXApp#run runs in,
after clicking the Ok button, widgets on the main window react to user actions by that
annoying beeping, and do nothing.

Here’s the code

require “fox”

class MyApp < Fox::FXApp

include Fox
    
def initialize
    super("test")
    @window = TopWindow.new(self)
    create
    @window.show
    run
end

end

class TopWindow < Fox::FXMainWindow

include Fox

def initialize(app)
    super(app, "test", nil, nil, DECOR_ALL, 100, 100, 200, 200)
    FXButton.new(self, "exit").connect(SEL_COMMAND) do
        exit
    end

    FXButton.new(self, "Click me").connect(SEL_COMMAND) do
        Thread.new{
            puts Fox::FXMessageBox.information(self, Fox::MBOX_OK, "thanks","Thanks you for clicking")
        }
    end
end

end

MyApp.new

If you comment the Thread.new line, all is fine. If you don’t, see what happens after closing the message window.

What is even more interesting is that when I close the window using my window manager, "Segmentation Fault"
message is shown.

What’s wrong?

ruby 1.8.0 on Linux
FoX version : 1.0.48
FXRuby version: 1.0.27

···


Best regards,
Yuri Leikind

Yuri Leikind wrote:

What’s wrong?

It is not immediately obvious to me what is wrong, but I can definitely
reproduce the problems you’re describing. I have just filed an FXRuby
bug report here:

http://sourceforge.net/tracker/?func=detail&atid=120243&aid=852888&group_id=20243

Lyle