Mike Werner wrote:
> Has anyone run into the situation where some of their widgets were being
> spontaneously relabeled?
It sounds like you might be using label() instead of copy_label().
label() does not make a copy of the string, it uses the string
passed to it. This means if that string is changed later or is
deallocated, the behavior of the widget will follow those changes.
Only use label() if you're setting the label to a fixed string
or to a string that for sure will remain allocated for as long
as the widget being labeled. eg:
widget.label("Testing"); // OK
{
static char s[80]; sprintf(s, "Frame %04d", 1234);
widget.label(s); // OK: s is static
}
What you don't want to have is this:
{
char s[80]; sprintf(s, "Frame %04d", 1234);
widget.label(s); // BAD! (s goes out of scope
before widget does)
}
..or this:
{
static char s[80];
sprintf(s, "Frame %04d", 1234); widget1.label(s); // OK:
s is static
sprintf(s, "Frame %04d", 4567); widget2.label(s); // BAD!
Reusing s[] will cause widget1 and widget2 to have same value
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk