After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 312259 - GMainContext refcounting issue
GMainContext refcounting issue
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gobject
2.9.0
Other Linux
: High critical
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2005-08-01 17:03 UTC by Mark McLoughlin
Modified: 2006-01-09 14:13 UTC
See Also:
GNOME target: ---
GNOME version: 2.11/2.12


Attachments
pygtk-take-a-ref-on-gmaincontext.patch (1.03 KB, patch)
2005-08-01 17:05 UTC, Mark McLoughlin
none Details | Review

Description Mark McLoughlin 2005-08-01 17:03:54 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.
Comment 1 Mark McLoughlin 2005-08-01 17:05:19 UTC
Created attachment 50080 [details] [review]
pygtk-take-a-ref-on-gmaincontext.patch
Comment 2 Manish Singh 2005-08-01 22:53:29 UTC
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.