Alvin wrote:

> Alvin wrote:
> 
>> Hello,
>> 
>> <snip>
>> 
>> The segfault is happening when I make a copy() of image(). From what I
>> can see using gdb is that image() doesn't have any width and height??
>> 
>> This is strange because the app is created using FLUID and the image is
>> set using FLUID (fluid stores the RGB data in the cxx file).
>> 
>> If I comment out the make_deimage() call in Fl_Image_Button::image(),
>> then the app appears as normal - with the image shown on the widget.
>> 
>> What am I doing wrong?
>> 
>> Alvin
> 
> Ok, this is not an issue with calling make_deimage() withing
> Fl_Image_Button::image().
> 
> After more testing, I have narrowed the problem to a Fl_Double_Window that
> I create manually (not in FLUID).
> 
> What I do is have have a global Fl_Double_Window *wnd2 which is 'new'ed in
> the implementation file. So the object is created as the app is loading
> (static construction??)
> 
> I believe that this happens before the main fltk app and
> fl_register_images() is called. So, this isn't a FLTK bug at all. It has
> something to do with the (implicit) order of how the windows in the apps
> are constructed.
> 
> Sorry for the noise.
> 
> Alvin

I think I am on the right track with the static initialisation. Using gdb I 
have determined that the ctor for the window that is being created is called 
before the static Fl_RGB_Image object is constructed?

This is my situation:

mywindow.fl
 - contains buttons with images
 - images are selected and stored using FLUID
- Image exist as "static Fl_RGB_Image image_ok(......)" inside the .cxx file
- cxx file is created by FLUID

My app, I have

In functions.h, I have
extern MyWindow *mywnd;


In functions.cpp, I have
MyWindow *mywnd = new MyWindow(0, 0, 400, 400, "My Window");


Using the stack in gdb, I can see that the ctor for MyWindow is called 
before the constructing the image_ok object.

If I move "mywnd = new MyWindow(0, 0, 400, 400, "My Window");" into a 
function and have the app call that function, then everything is fine.

What have I done wrong? I rather keep what I have where the MyWindow object 
is new'd as the application is loading rather than new'ing it by calling a 
function. Again, this only appears to be a problem when setting the image 
and trying to access that image inside the widget's image() function.

Alvin



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to