> On 30.03.2010, at 20:31, Andreas wrote:
> > Hi everyone!
>
> Please note that questions for FLTK 2 are not likely to get fast
> and high quality replies, because there are no active FLTK 2 dev's
> around here any more.
>
> I don't know much of FLTK 2, but I think that your problem is not
> directly related to FLTK 2, but a standard C(++) problem.
>
> > This is my code for creating the MultiImage:
> >
> > fltk::MultiImage* GetButton(const char *str)
> > {
> >    string first = ".\\Resource\\Images\\button";
> >    string end = ".png";
> >    string variable = str;
> >
> >    string str0 = first+variable+end;
> >    string str1 = first+variable+"_hover"+end;
> >    string str2 = first+variable+"_push"+end;
> >    string str3 = first+variable+"_inactive"+end;
>
> These variables above are local variables in your subroutine
> GetButton, and thus go out of scope with the following return
> statement, an so do all your strings. You need static variables
> or malloc'd variables to keep the strings alive.
>
> >    return new fltk::MultiImage(*(fltk::SharedImage::get(str0.c_str())),
> >          fltk::HIGHLIGHT, *(fltk::SharedImage::get(str1.c_str())),
> >          fltk::PUSHED, *(fltk::SharedImage::get(str2.c_str())),
> >          fltk::INACTIVE_R, *(fltk::SharedImage::get(str3.c_str())));
> > }
>
> Hope, this is more "trustworthy" than your current solution ;-)
>
> Albrecht

I assume that SharedImage::get(..) loads the images when I make the call, 
right? So in that case the images should already be loaded and the strings not 
needed anymore when my MultiImage is returned.

Please correct me if I'm wrong and I'll make the necessary changes.

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

Reply via email to