Re: How to determine if a GObject is "contained"?



Hans Oesterholt-Dijkema wrote:
L.S.,

I'm writing a language binding for mzscheme to Gtk. I recently
derived a method to do memory mangement for GtkObject and
GObjects. An artikle about it can be read here:

http://www.elemental-programming.org/mzgtk2-mzgtk2-memory-management.html

There is however one case, where I'm in trouble. See /"The containment assumption falsified"/
in this artikle. Now I have one burning question:

Is there a decision procedure to determine if some GtkObject or
GObject contains an other GObject? E.g., a GtkImage object will
contain a GdkPixmap. When asked for, with gtk_image_get_pixmap,
the reference count of the returned GdkPixmap will be 1. If my typemapper
can decide somehow (e.g. by questioning the GdkPixmap GObject) that
it is contained withing another object (the GtkImage GObject), my typemapper
can increase the reference count by 1.


    I'm not exactly clear as to why you must absolutely keep an
eye on every GObject created, note that a GtkImage which uses a
GdkPixbuf delagate is not really a "parent child" relationship.

The straight forward answer to your question is "no", you can
not find out what code segment is responsable for a given object,
GtkWidgets have a logical "heirarchy" which can be navigated
with the GtkWidget/GtkContainer APIs; if a GtkImage is finalized,
it is safe to say that it has released any references for any
external resources used.

Cheers,
                          -Tristan




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