Re: g_object_ref and g_object_unref in widget implementations
- From: Tristan Van Berkom <tvb gnome org>
- To: Bastiaan Veelo <bastiaan sarc nl>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: g_object_ref and g_object_unref in widget implementations
- Date: Sat, 06 Oct 2007 10:09:04 -0400
On Sat, 2007-10-06 at 13:09 +0200, Bastiaan Veelo wrote:
Hi,
I am writing my own widget, and while looking at the widgets in GTK I
notice the following.
If a widget draws on its parent GdkWindow, you generally see
widget->window = gtk_widget_get_parent_window (widget);
g_object_ref (widget->window);
But widget->window is not g_object_unref-ed anywhere in the widget
implementation. Why shouldn't it?
They are unreffed, it just takes a little while getting used to
reading the object oriented C code :)
Notice:
gtkbutton.c::realize() does what you say, get_parent_window(),g_object_ref().
gtkbutton.c::unrealize() does some gtkbutton specific things, and chains up
to the parent implementation with:
GTK_WIDGET_CLASS (gtk_button_parent_class)->unrealize (widget);
gtkwidget.c::unrealize() is the implementation that it will fallback
on, thats where widget->window will be unreffed if GTK_WIDGET_NO_WINDOW(widget).
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]