Re: Work woth GUI from a thread that was made by pthread_create function



On Mon, Feb 11, 2002 at 11:11:31AM +0000, Michael Meeks wrote:
> Hi Pawel,
> 
> On Thu, 2002-02-07 at 20:36, Pawel Salek wrote:
> > You need to lock gdk mutex before entering the main loop.
> > 
> >      gdk_threads_enter();
> >      gtk_main();
> >      gdk_threads_leave();
> 
> 	You also need to drop locks before doing things eg.
> 
> 	gdk_threads_leave ();
> 	do_some_gtk_call ();
> 	gdk_threads_enter ();
> 
> 	eg. in signal handlers, and such like - but it very much depends if the
> signal is emitted from the Gtk mainloop, or explicitly from another
> source, if from another source then depending on whether you're in a
> mainloop you need to lock,unlock or unlock,lock in a not altogether
> clear fashion.
> 
> 	In short I'd avoid threads & Gtk+ like the plague.

In general I'd agree.  Pan is a pthreaded app, and I would've saved myself
a lot of pain if I'd avoided pthreads.

That said, 0.11.2 has some small pieces of code to make pthreaded gtk+ apps
a little less painful.  Anyone hell-bent on pthreads may want to look at its
source.



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