tags:

views:

50

answers:

1

Hi,

Question regarding GtkBuilder. When we unref builder pointer does it destroys all the screens/widgets the builder had created?

if( builder_ptr )
    g_object_unref(G_OBJECT(builder_ptr));

Suppose we have created one screen using Glade/XML with some 2-3 top_level windows in it

gtk_builder_add_from_file(builder_ptr, "Test.glade", &error )

and generated GtkBuilder pointer (as above) so after deleting this pointer does it deletes created Windows or do we need to manually delete these windows?

Thanks,
PP.

+2  A: 

From the documentation:

A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call gtk_widget_destroy() to get rid of them and all the widgets they contain.

So, no, GtkBuilder does not do this for you, you have to do it yourself.

unwind
Thanks, so i have to call `gtk_widget_destroy()` on every top level window constructed by builder that's what you are saying?
PP
@PP: Yes, that is what the documentation is saying.
unwind