FoX: FXMessageBox and threads

Y

Yuri Leikind

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top