Re: g_idle_add(): limits?



On Tue, 9 Mar 2010 10:06:19 +0100
"fkater googlemail com" <fkater googlemail com> wrote:
Hi,

I make heavy use of g_idle_add(), and encounter this problem:
It seems that the idle functions aren't called sometimes.

To track that: I used a counter before g_idle_add() and one
inside the idle function (always executed once only).  When
the app is closed, the counters are sometimes not equal.

You probably had some stacked in the event queue when you terminated
the main loop.  The documentation for g_main_loop_quit() states "Note
that sources that have already been dispatched when g_main_loop_quit()
is called will still be executed", which implies that sources which
have been added but not dispatched will not execute.  Presumably this
extract from the documentation is principally intended to refer to cases
where a different thread from the main loop thread has added a source.

Assuming that is right, any sources you add before calling
gtk_main_quit() without returning control to the main loop will not be
executed.  I think it probably also means that if you call
gtk_main_quit() in a GTK+ signal handler, which will have a higher
priority than a default idle event, a stacked idle callback will also
not be called (that depends on what the documentation that I have
referred to means by "dispatched").

Chris



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]