Package: glib

Function g-main-context-find-source-by-id

Lambda List

g-main-context-find-source-by-id (context source)

Arguments

context -- a g-main-context instance, if null-pointer, the default context will be used
source -- an unsigned integer source ID, as returned by the g-source-id function

Return Value

The g-source instance if found, otherwise, a null-pointer.

Details

Finds a source given a pair of context and ID. It is a programmer error to attempt to look up a non-existent source.

More specifically: source IDs can be reissued after a source has been destroyed and therefore it is never valid to use this function with a source ID which may have already been removed. An example is when scheduling an idle to run in another thread with the g-idle-add function. The idle may already have run and been removed by the time this function is called on its (now invalid) source ID. This source ID may have been reissued, leading to the operation being performed against the wrong source.
 

See also

2021-12-10