Hello,
I am trying to derive a new widget (Fl_Image_Button) from Fl_Button that
creates a deactivated image (deimage) auto-magically from the widget's
image().
Here is the Fl_Image_Button::image() function that I have:
void Fl_Image_Button::image(Fl_Image *a)
{
// Clear the old auto-deimage if we have one
// dimg is a Fl_Image* for the automatically created deimage file
if(dimg)
{
delete dimg;
dimg = 0;
Fl_Button::deimage(0);
}
Fl_Button::image(a);
// If a deimage has not been set for image, a, then
// create a new deimage based on image, a.
if(a && !Fl_Button::deimage())
make_deimage();
}
Here is the function I used to created the deimage:
void Fl_Image_Button::make_deimage()
{
if(!image())
return;
// Release our current deimage
if(Fl_Button::deimage() && (Fl_Button::deimage() == dimg))
{
delete dimg;
dimg = 0;
Fl_Button::deimage(0);
}
// create the desaturated image
Fl_Image *new_img = image()->copy(); //<--- SEGFAULT HERE
new_img->desaturate();
Fl_Button::deimage(new_img);
}
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
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk