Re: Xlib: unexpected async reply (sequence #####)!



On Sun, 2007-08-05 at 20:11 +0800, Gregory Hosler wrote:
Your example clears up alot of stuff for me. One of my questions (that your
example pretty much clarifies for me), was "what do I g_idle_add()" ?
If I understand correctly, you basically add callback functions, and in
particular, ones that are gtk/gdk related (i.e. that deal with the displaying of
widgets).

is this more or less correct ?

Yes. The callback functions can contain chunks of widget manipulation
code that you wish to run at some point when the main thread's main
event loop becomes available. If you wish to run the code only once per
g_idle_add(), you must return FALSE from the callback.


so, um, when a g_idle_add does a "gtk_widget_show()" on a widget, and that
widget would get displayed as part of the main thread.

AFAIK, yes.

Am I correct to say that things like gtk_label_new(), and all the related calls
to build a label widget, can be done in a thread, but the "show" must be done in
the main loop (via the g_adle_add() call) ?

I would be more prudent than that. The process of creating widgets may
involve retrieving font size information and stuff like that, so it'd
best be done on the main thread.

If there a list (or guideline) of which gtk_calls should be done in the idle,
and which need not be ?

I'd put them all on the main thread. In fact, I will go so far as to say
that, if you were to compile only the code that's part of your
"side-thread(s)", you shouldn't need gtk+ at all.

HTH,



Gabriel




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