Re: [gtk-list] Re: GTK--: Gtk_Notebook::append_page question
- From: Ionut Borcoman at home <borco mailbox ro>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: GTK--: Gtk_Notebook::append_page question
- Date: Tue, 14 Jul 1998 20:48:49 +0000
Tero Pulkkinen wrote:
>
> Ionut Borcoman at home <borco@mailbox.ro> writes:
> > I want to add some pages to a notebook. I am using something like this:
> >
> > frame0.set_usize( 200, 200 );
> > frame0.border_width( SPACING );
> > notebook.append_page( &frame0,new Gtk_Label("a page"));
> > frame0.show();
> >
> > My question is this:
> >
> > Will the memory allocated for the label by dealocated corectly when the
> > notebook or notebook page is deleted ? Will this kind of declaration
> > ("new Gtk_Label("a page")") produce memory leaks ?
>
> With all gtk-- containers, including notebooks, the ownership of the
> items inserted to it are NOT transferred to the container. Thus you
> must delete everything yourself what you allocate.
Than my style of appending is not good. :( And I have to keep a lot of
variables, otherwise not needed. The biggest problem is how to name all
this bunch of widgets ! :)
And it means that the piece of code from bellow is also leaving some
memory that cannot be freed, isn't it ?
Gtk_Label *label;
label = new Gtk_Label("xxx");
table0.attach( label, 0, 1, row, row+1, GTK_FILL, GTK_FILL);
label->set_alignment( 0.0, 0.5 );
label->show();
row++;
// use the same pointer variable for the next widget !!!
// advantages: only one pointer variable
// also cut-and-paste of code works easy
label = new Gtk_Label("yyyyyyyyyyyyyyyyyyy");
table0.attach( label, 0, 1, row, row+1, GTK_FILL, GTK_FILL);
label->set_alignment( 0.0, 0.5 );
label->show();
Any ideea about how to do something similar without memory leaks ?
Ionutz
PS: Thanks for the Gtk_Table::Gtk_Table(gint rows=1, gint columns=1, gint homogeneous=FALSE); The defaults are always usable.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]