[Fxruby-users] Segmentation fault when changing the icon for a button
Status: Inactive
Brought to you by:
lyle
|
From: Carsten E. <ca...@ci...> - 2003-12-08 08:40:05
|
Hi,
I'm banging my head against this problem for days now: I have a button
which displays an icon and then when the button is pressed it should
display another icon. So the first icon is displayed fine but when I
press the button the app chrashes with a segmentation fault. I'm testing
this with the 'Pragmatic Installer 1.8.0-10' on Windows 2000.
Here's the code:
#------------------------------------------
require 'fox'
include Fox
class MainWindow < FXMainWindow
# load a png image from file
def loadIcon(filename)
begin
icon = nil
File.open(filename+".png", "rb") { |f|
icon = FXPNGIcon.new(getApp(), f.read)
}
icon
rescue
raise RuntimeError, "Couldn't load icon: #{filename}"
end
end
# initialize the window
def initialize(app)
super(app, "Test", nil, nil, DECOR_ALL, 0, 0, 0,0, 0, 0)
button = FXButton.new(self,"")
# set the buttons icon to the first image -> works well.
button.icon = loadIcon("first")
# when the button is pressed, change the icon
# to the second image -> BOOM!
button.connect(SEL_COMMAND) { button.icon = loadIcon("second") }
end
# create the window
def create
super
show(PLACEMENT_SCREEN)
end
end
# create and run the application
app = FXApp.new("Test", "Test")
MainWindow.new(app)
app.create
app.run
#------------------------------------------
It also doesn't work for FXlabel and FXImageView. What am I doing wrong
here?????? Help!
Carsten.
|