[email protected] wrote:
The reason I thought it should work is that FXApp::run() and
FXApp::runWhileEvents() are doing basically the same thing, with
slightly different logic. So if it is safe to unwind from
runWhileEvents and then re-enter the event loop, then it should be
safe to do so with run as well.
OK, I managed to reduce my problem to the following test program: as
soon as you try to add a “buggy tab”, the GUI starts to mess up. The
result, you will see, is different if you start by adding a buggy tab,
or if you start by adding a normal tab.
Maybe I need to call some kind of “refresh” after the exception is
raised?
#!/usr/bin/ruby
require ‘fox16’
include Fox
class MyFXTabItem < FXTabItem
end
class MyBuggyFXTabItem < FXTabItem
def initialize(text, icon=nil, data=nil)
super
raise Exception.new
end
end
class MyWindow < FXMainWindow
def initialize(app)
super(app, "Window", nil, nil, DECOR_ALL, 0, 0, 600, 350)
# Menu bar stretched along the top of the main window
menubar = FXMenuBar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
# File menu
filemenu = FXMenuPane.new(self)
FXMenuTitle.new(menubar, "&File", nil, filemenu)
FXMenuCommand.new(filemenu, "&Quit\tCtl-Q\tQuit the application",
nil, app, FXApp::ID_QUIT)
# Content
contents = FXVerticalFrame.new(self, LAYOUT_FILL_X|LAYOUT_FILL_Y)
# Tabs
@tabbook = FXTabBook.new(contents,:opts =>
LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_RIGHT)
FXButton.new(contents, "add tab").connect(SEL_COMMAND) do |sender,
selector, data|
# First item is a list
tab = MyFXTabItem.new(@tabbook, “&Simple List”, nil)
frame = FXHorizontalFrame.new(@tabbook,
FRAME_THICK|FRAME_RAISED)
simplelist = FXList.new(frame, :opts =>
LIST_EXTENDEDSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
simplelist.appendItem(“First Entry”)
simplelist.appendItem(“Second Entry”)
simplelist.appendItem(“Third Entry”)
simplelist.appendItem(“Fourth Entry”)
frame.create
tab.create
tab.show
end
FXButton.new(contents, “add buggy tab”).connect(SEL_COMMAND) do
|sender, selector, data|
# Second item is a file list
tab = MyBuggyFXTabItem.new(@tabbook, “F&ile List”, nil)
frame = FXHorizontalFrame.new(@tabbook,
FRAME_THICK|FRAME_RAISED)
filelist = FXFileList.new(frame, :opts =>
ICONLIST_EXTENDEDSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y)
frame.create
tab.create
tab.show
end
end
def create
super
show(PLACEMENT_SCREEN)
end
end
if FILE == $0
$app = FXApp.new(“Attik System”, “FXRuby Test”)
MyWindow.new($app)
$app.create
begin
$app.run
rescue Exception => e
FXMessageBox.information($app, MBOX_OK, “Error”, “An exception was
raised”)
retry
end
end