Re: Idle Function Not Getting Called

Firstly, I probably should apologize. I've been going round and round with this problem for a long time. I had probably hit a boiling point and sent my post as a knee-jerk reaction. So, my post may have had a bad tone about it.

Also, my experience working with this sort of problem is not extensive and there are probably some things I do not understand which may add to my frustration.

However, the idle function gets called fine with the following code:

    g_idle_add ((GSourceFunc) idlefunc, NULL);
    while (gtk_events_pending ())
        gtk_main_iteration ();

What would account for such behavior?

As I said, you probably aren't letting the main loop run after adding your idle function. The while loop there explicitly forces the main loop to run, but it's generally not good practice unless you know what you're doing.

I thought I had checked this extensively but still ... you may be right. I'll check further.

I have a situation where an idle function does NOT get called with
the following code:

     g_idle_add ((GSourceFunc) idlefunc, NULL);


     while (gtk_events_pending ())
         gtk_main_iteration ();
     g_idle_add ((GSourceFunc) idlefunc, NULL);

Assuming there is no coding error in your program which causes an event
in the main loop to block (including a blocking g_idle_add() callback),
use g_idle_add_full() and give the callback a higher priority in the
event queue to put it ahead of the other events.

G_PRIORITY_HIGH will even put it above any GDK drawing functions (not
to be recommended though).

I tried G_PRIORITY_HIGH_IDLE with similar results ... the idle function is called only with the following code:

    g_idle_add_full (G_PRIORITY_HIGH_IDLE, (GSourceFunc) idlefunc, NULL, NULL);
    while (gtk_events_pending ())
        gtk_main_iteration ();

If the while loop is not part of the coding then the idle function (idlefunc) is not called.

The difference with using G_PRIORITY_HIGH_IDLE is that some of the buttons inside the dialogs drawn in the idle function are not displayed. But they still react to user clicks if clicked in the right area. I expect this is linked to your "GDK drawing functions" statement above.

I was just looking for any kind of help with my knee-jerk post since I have noone to talk with about such problems (yes ... I'm friend-less :). I have to keep digging.

Marshall Lake -- mlake mlake net --

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