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 662257 - GSource reference counting semantics are completely undocumented :(
GSource reference counting semantics are completely undocumented :(
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: docs
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-10-20 00:18 UTC by Ryan Beasley
Modified: 2018-05-24 13:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Ryan Beasley 2011-10-20 00:18:07 UTC
A project I work on uses GLib's main loop at its core.  I usually come back to this project after a few (or many) months working on other stuff, so I have a tendency to forget a fair amount of specific knowledge about GLib, and I have to resort to the published APIs at http://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html#GSource .

One thing I've repeatedly had to fall back to reading sources to figure out are the reference counting semantics for event sources.  It would be extremely helpful if the docs noted a returned source's initial reference count (g_source_new: 1 vs. g_timeout_add: 2, since attaching it to a context increments the count?), such that users know when they have to clean things up and how.

Thanks!
Comment 1 Matthias Clasen 2011-10-20 11:02:19 UTC
I agree that we should document this more clearly. However, it is not trivial. 
The docs need to say that

1. g_timeout_add, g_idle_add, g_source_remove etc are just convenience api to work with the default context. When you are using these, you are never explicitly dealing with GSource structures.

2. GSource structures are ref-counted. g_source_new, g_timeout_source_new, etc return a new reference. Free with g_source_unref(). However, if a source is attached to a main context, you need to use g_source_destroy()
Comment 2 GNOME Infrastructure Team 2018-05-24 13:28:03 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/467.