Re: Refreshing the GUI without gtk_main ()



On Sat, Apr 17, 2004 at 12:15:05AM +0100, Chris Seaton wrote:

You should never, ever have IO in the same thread as your GUI. That's a
major no-no. Have the GUI running in the main thread, and do your IO in
a new thread.

Sorry, but that is a bunch of crap (or you're 17 days late). 
The whole point of giochannels and select loops in general (which
is what GMainLoop essentially is) is to allow multiplexing on
different I/O and timeout sources. There are tons of working
examples of single threaded GUI programs that handle I/O
from pipes and sockets.

glib is full of facilities to provide async i/o in single
threaded applications so this statement is particularly
egregious on the gtk-app-devel list.

On the otherhand I would totally agree with the rule that you should
relegate all GUI operations to one thread and use safe queues for
interthread communication. And, above all, it is best to keep things
single threaded if you can.


Use gdk_threads_enter() and _leave() before and after calling GUI
functions from the IO thread.

Oddly enough, this suggestion contradicts your earlier one about not
having IO in the GUI thread.

-jkl



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