Multi frame image viewer not updating

Hi. I’m relatively new to FXRuby, and Ruby in general, so hopefully I
have just overlooked something simple. I am making a program that has a
image viewer on one side that shows multiple jpg’s in a vertical frame.
Unfortunately, when I attempt to change the images in the viewer,
nothing happens. I’ll post the relevant code. I may make a type in the
generalization of it, so if you spot one, that’s not the solution:

(somewhere in a FXMainWindow class)
@stackViewerWindow = FXScrollWindow.new(@stackViewerFrame,
LAYOUT_FILL_X|LAYOUT_FILL_Y)
@stackViewer = FXVerticalFrame.new(@stackViewerWindow,
LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y, 0, 0, 357)
@pButton2.connect(SEL_COMMAND) do
@stackViewer = FXVerticalFrame.new(@stackViewerWindow,
LAYOUT_FIX_WIDTH|LAYOUT_FILL_Y, 0, 0, 357)
random_object.display(theApp, @stackViewer)
end

(in some random_object class)
def display(theApp, target)
number = @cards.length
image = Array.new
imageView = Array.new
number.times do |number|
filename= @cards.at(number).card_id.to_s + “.jpg”
image[number] = FXJPGImage.new(theApp, nil,
IMAGE_KEEP|IMAGE_SHMI|IMAGE_SHMP)
FXFileStream.open(filename, FXStreamLoad) do |stream|
image[number].loadPixels(stream)
end
image[number].create
imageView[number] = FXImageFrame.new(target, image[number])
end
end

Thanks for your help in advance!

On 1/19/07, Raj S. [email protected] wrote:

Hi. I’m relatively new to FXRuby, and Ruby in general, so hopefully I
have just overlooked something simple.

You seem to have overlooked the FXRuby mailing list, among other things:

http://rubyforge.org/mailman/listinfo/fxruby-users

end
image[number].create
imageView[number] = FXImageFrame.new(target, image[number])
end
end

It looks like you aren’t calling create() on the new FXImageFrame
after you instantiate it. Try adding this:

imageView[number] = FXImageFrame.new(target, image[number])
imageView[number].create # add this line

Hope this helps,

Lyle

Thanks for the link to the mailing list.

The image viewer example code doesn’t ever do that. Are you sure it’s
necessary? In my readings so far I never see create called on the
FXImageFrame, only the FXImage. . .after adding that line I get a seg
fault.

Lyle J. wrote:

It looks like you aren’t calling create() on the new FXImageFrame
after you instantiate it. Try adding this:

imageView[number] = FXImageFrame.new(target, image[number])
imageView[number].create # add this line

Hope this helps,

Lyle

On 1/19/07, Raj S. [email protected] wrote:

The image viewer example code doesn’t ever do that. Are you sure it’s
necessary?

Yes. If you are creating any resource, whether it’s an image, an icon,
a font, a window, etc. after the application is running, you need to
call create() on that resource to realize it. See this FAQ for more
information:

http://www.fox-toolkit.com/faq.html#CREATELATER

… after adding that line I get a seg fault.

OK. Without seeing the code in its entirety, I can’t say for sure what
the problem is – can you perhaps send me the program (or another
program that demonstrates the problem) off-line?

Thanks,

Lyle

I read the link, nevermind. Let me work on it some more. . .

Lyle J. wrote:

Yes. If you are creating any resource, whether it’s an image, an icon,
a font, a window, etc. after the application is running, you need to
call create() on that resource to realize it. See this FAQ for more
information:

http://www.fox-toolkit.com/faq.html#CREATELATER

I already call create on the instances of FXJPGImage, I need to call it
on the Image and the ImageFrame? The image viewer example only calls it
on the Image.

OK. Without seeing the code in its entirety, I can’t say for sure what
the problem is – can you perhaps send me the program (or another
program that demonstrates the problem) off-line?

Thanks,

Lyle

I might be able to, let me work on altering it so you can use arbitraty
images.

So I read through that faq, learned a couple things, but I’m still
having the seg fault problem. I agree, I need to call create on a
couple things, and it sounds like I should be calling refresh, or
possibly forceRefresh on my FXApp? None of it helps, and I still have
no idea what could be causing the seg fault. I do know what line is
causing it, it’s the create call to the imageFrame array. Numerous
other create calls had no errors, but that method brings the seg fault.