Stjepan Rajko wrote:
> Hi FLTK developers,
> 
> This is my first post here, so first of all thanks for developing an
> easy to use GUI library.
> 
> And for my question: I recently started using FLTK2 and found that
> fltk::Widget does not store it's own label.  Instead, it only stores
> the const char * passed to it, which seems strange.  Among other
> things, it means you can't initialize the label with a temporary.  Is
> there a reason the widget doesn't hold a, say, std::string that stores
> the text of the label?
> 

It is a minor performance.  Widget is a smart class which can either 
manage the string it holds or not.  The default is to not manage the 
const char*.

However, as soon as you use:
        widget.copy_label("something")

The "something" is actually strdup() and Widget will then set an 
internal flag to eventually free the label if it changes again or the 
widget is destroyed.

Thus, if you want to use generated strings that are temporary, pass them 
onto the widget with copy_label, not with the constructor or with label().



-- 
Gonzalo Garramuño
[EMAIL PROTECTED]

AMD4400 - ASUS48N-E
GeForce7300GT
Xubuntu Gutsy

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

Reply via email to