Re: g_idle_add() clarification





On Tue, Jan 20, 2015 at 7:55 PM, Ian Chapman <ichapman videotron ca> wrote:
Thanks Chris,
    I think that not only is my code broken my idea on how to do what I want is broken.  I must fix that before I start on the code.

    My starting point was two button, scan off and scan on in glade.  Scan on sets a flag and it scans til the off button is pressed.  So the off button could not be pressed til end-of-scan, a situation commonly known as a deadly embrace in hardware design.  After that g_idle_add() was pointed out to me and I've been innovating rather blindly ever since.

    I interpreted g_idle_add() as inserting Scanning() into the main loop and if Scanning returned FALSE it was removed from the main loop.  So I guess I'm not understanding the following explanation of
guint g_idle_add(GSourceFunc function, gpointer data); :-

it is worse than this. you don't understand the difference between naming a function and calling a function. consider the following code:

gboolean foo() { return FALSE; }
foo; /* names foo */
foo(); /* calls foo */

g_idle_add (foo, NULL); /* adds foo to the idle part of the main event loop */
g_idle_add (foo(), NULL); /* calls foo and adds its return value, FALSE (aka 0 or NULL) to the idle loop */
 


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