GNOME Bugzilla – Bug 312259
GMainContext refcounting issue
Last modified: 2006-01-09 14:13:48 UTC
This test case: --- #!/usr/bin/env python import gobject import time def do_idle(): print "foo %d" % time.time () return True gobject.timeout_add (500, do_idle) main_loop = gobject.MainLoop () time.sleep (1) while main_loop.get_context ().pending (): main_loop.get_context ().iteration (False) time.sleep (1) --- crashes from what looks to be this: --- Fri Jul 1 18:51:15 PDT 2005 Manish Singh <yosh@gimp.org> * gobject/pygmaincontext.c: unref the underlying GMainContext upon object destruction. Some minor cleanups as well. --- Problem is that pyg_main_context_new() is the only place where we actually take a ref on the GMainContext(). Two other places don't take a ref. Attaching a patch.
Created attachment 50080 [details] [review] pygtk-take-a-ref-on-gmaincontext.patch
Thanks for pointing out the problem, it's fixed in CVS. I didn't use your patch however, but made a convenience constructor instead. You missed the g_source_get_context wrapper as well.