[pygtk] is GObject initialized?

Paul Pogonyshev pogonyshev at gmx.net
Sun Dec 3 20:24:26 WST 2006


Johan Dahlin wrote:
> 
> > Is there a non-hackish way to find if GObject is initialized or not?
> > It seems non-initialized objects have zero hash, while initialized
> > have non-zero, but it is probably a hack to depend on it...
> >   
> Using the hash is fine.
> It's currently implemented like this:
> 
> static long
> pygobject_hash(PyGObject *self)
> {
>     return (long)self->obj;
> }
> 
> self->obj is NULL if the object isn't initialized and will return 0.
> If it's initialized, self->obj will return the memory address of the 
> GObject pointer.
> 
> This code is unlikely to go away and you can safely depend on it.

Thanks.

Paul


More information about the pygtk mailing list