Re: Idle Function Not Getting Called



On Wed, 9 Sep 2009 12:23:07 -0400 (EDT)
Marshall Lake <mlake mlake net> wrote:



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.

Then you must have some function blocking between your call to
g_idle_add_full() and control returning to the main loop.

Anything in a GTK+ signal or event handler must not block.  This
means in practice that nothing should block after your call to
gtk_main().

After spending more time with my code I'm just not seeing it.  Below
is the pertinent code.

AddName() is called from a drop-down menu item.

Via debug code I've seen that the program flow is as it should be ...
all functions are exited.  The first idle function (PlayNetGame()) is
added, executed, and exited as it should be.  The second idle
function (PlayTheGame()) is added but is never called.

Does anyone see what might be blocking the call of PlayTheGame() or
have any other suggestions?

I have not tried to find it in the code, but as your application is
multi-threaded you are showing the symptoms of a deadlock, either by
recursive locking or more likely by out of order locking.  Can you run
the code through a deadlock checker, or if not can you by appropriate
breakpoints find out if it is occurring in a mutex lock?

Although not relevant to your problem I should add to my comment that
you should not block after your call to gtk_main().  You can block in a
further recursive call to gtk_main() (modal dialogs generally do that)
but that is fine as main loop events continue to be serviced.

Chris



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