GNOME Bugzilla – Bug 790948
GSourceFuncs documentation is confusing: when will dispatch be called?
Last modified: 2017-11-29 19:21:08 UTC
I am confused by the documentation of GSourceFuncs. The documentation indicates that dispatch is only called if either prepare or check returns TRUE. It also indicates that if prepare or check is NULL, then it is treated as if that function returned FALSE. So if both prepare and check are NULL, then dispatch should never be called. However, the GSocketSource implementation until recently used NULL for both prepare and check. So I am missing something. Clearly, in practice, both functions can be NULL, and the source will actually be dispatched, contrary to the documentation. Looking at the implementation of g_main_context_prepare(), I see that g_source_set_ready_time() effectively overrides the result of prepare, ensuring that dispatch is called. This is sort of documented in the description of g_source_set_ready_time(), but the interaction between the ready time and prepare/check is not mentioned.
Created attachment 364575 [details] [review] gmain: Improve documentation of GSourceFuncs We should more clearly indicate that a source ready time will result in a source being dispatched even if prepare and check never return TRUE.
Review of attachment 364575 [details] [review]: Looks good to me.
Attachment 364575 [details] pushed as 7f639fd - gmain: Improve documentation of GSourceFuncs