GtkWidgets, Who owns what?



I have some questions about various situations and whether or not GTK or my
program is responsible for freeing the objects/memory in these situations.

Situation 1:  I have a (visible) form, with a container, with a widget.  I
close the form.  Are all the widgets (and the form) cleaned up?

Situation 2:  I have the same as above, but the window is never shown, so
is never closed. However, gtk_main_quit() is called.  Am I responsible for
the cleanup of the window?  (And if I destroy the window manually, will it
clean up all of its children?)

Situation 3:  I have a container, that has children, but that container is
never added to a form.  Am I responsible for cleaning up the container?
And, as above, if I destroy the container, will it clean up its children,
or am I responsible for that?

Situation 4:  I have a container with children (as in Situation 3), but it
was added to a form at one point (and later removed).  Am I responsible for
that (are we back to Situation 3 at that point?)/

With those 4 situations, is the following the correct way to clean up any
of the objects that I am responsible for?

        g_object_ref_sink(G_OBJECT(widget));
        gtk_widget_destroy(widget);
        g_object_unref(G_OBJECT(widget));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]