SkyFlash wrote:
> I just discovered that setLegend will copy my char* instead of copying
> the content, so if I pass in
> a constant like "Value" it crashes after the memory is out of scope.
This is odd, I don't think C-language string constants (literals)
should be destroyed or become invalid when they are "out of scope"-
Certainly the most typical legend usage I have is:
button->setLegend("My Button");
and it works fine. C++ standard library "strings" are an other thing,
and they might cause problems.
> Also if I pass in a temporary variable and delete
> it afterwards it crashes....
>
Yes, this is to be expected.
> How am I supposed to change the value of the legend of a widget after
> its created?
>
If I have needed to "inplace edit" widget legends I have either used
static char arrays or dynamically allocated memory buffers, which
I have then passed to setLegend. Of course for dynamic allocation the
buffer cannot be freed before the widget has been destroyed.
Eero
|