Calling "g_main_context_pending" increases reference count for the ready sources
Submitted by Areg Beketovski
Link to original bug (#479787)
Description
Please describe the problem:
Calling "g_main_context_pending" increases reference count for the ready sources, in the internal call to g_main_context_check. This function calls internal "g_main_context_iterate", with "dispatch" parameter set to "FALSE". Normally, whenever g_main_context_iterate is called with "dispatch" parameter set to "TRUE", internal call of "g_main_context_dispatch" decreases the reference count of the dispatched sources.
Steps to reproduce:
- 4 sources are attached to the newly created context, two of which with priority "-1" and two others with "1" and "2".
- First two sources will be marked as "READY" after internal call of "g_main_context_check" and reference count for them will be increased.
If "g_main_context_pending" would not have been called here, the following warnings would appear after the invocation of "g_main_context_unref" in the "for":
//********************************************************************* (process:7320): GLib-WARNING **: gmain.c:1417: ref_count == 0, but source is still attached to a context!
(process:7320): GLib-WARNING **: gmain.c:1417: ref_count == 0,
but source is still attached to a context!
//*********************************************************************
The absence of these warnings upon invocation of the sample shows that reference count for ready sources was increased during the call to "g_main_context_pending".
The detailed bug description can be found at:
http://linuxtesting.org/results/report?num=D0006
Version: 2.14.x