[pygtk] GTK warning

Jeffrey Barish jeff_barish at earthlink.net
Mon Feb 23 12:22:29 WST 2009

On Sunday 22 February 2009 10:51:02 Gian Mario Tagliaretti wrote:
> On Sun, Feb 22, 2009 at 6:09 PM, Jeffrey Barish
> <jeff_barish at earthlink.net> wrote:
> > I am getting a GTK warning that looks like this:
> >
> > /myprog.py:118: Warning: g_object_unref: assertion `object->ref_count >
> > 0' failed
> >   self['myimage'].set_from_pixbuf(mypb)
> >
> > I am having a problem debugging this error because I don't see that I am
> > unreferencing anything in line 118.
> I don't think it's you unreferencing but the GC that have collected
> your object leaving you with garbage,
> what if you do something like
> foo = [mypb]
> just after you create it, to keep a reference to mypb and see if helps.
> cheers

I think you got it.  I was inadvertently setting the pb twice.  Python would 
have abandoned the bindings from the first pass through the code the second 
time through and eventually garbage collected the objects.  I can imagine 
that GTK could have gotten upset at that point, although I haven't worked out 
all the details.  This hypothesis also explains why I never saw anything 
wrong.  I fixed my code so that the pb gets set only once and I'm doing more 
testing to see whether the intermittent warning appears again.  So far, it 
looks good.  Thanks for the suggestion.
Jeffrey Barish

More information about the pygtk mailing list