Re: trouble with gtk idle function callback



I found the bugs in my simulator code that were preventing my idle function
from working properly.  It was a combination of two things:

1)  In my (interface-independent) simulation loop, I periodically call
    a function in my gtk interface called gui_idle_callback(), which is
    intended to give the GUI a chance to process events.  The way I
    originally wrote this, it gets called before the first simulation
    cycle.  Which might have been OK, but...

2)  In my gui_idle_callback(), I simply wrote:

	gtk_main_iteration ();

    which should have been:

	while (gtk_events_pending ())
	  gtk_main_iteration ();

I had one serious bug which was apparently unrelated to this.  I was calling
gtk_idle_remove() from within the idle function.  Pennington's book set me
straight about this.  (If there was a warning about that in the online GTK+
docs at www.gtk.org, I missed it.)

This still leaves me with one more question:

Am I better off with:

1)  what I have now, which is that a single invocation of my idle callback
    will potentially run forever, but periodically use the while loop above
    to process events

2)  have my idle callback periodically return, so that events can be
    processed by gtk_main(), after which presumably my idle callback will
    be called again

It occurs to me that in case 1, perhaps I could be preventing other idle
callbacks from being executed.  I'm not installing any others myself, but
I don't know if there are some standard ones now (or perhaps will be in
the future).  So perhaps case 2 would be more elegant, or at least more
future-proof?

Thanks!
Eric




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