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
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