Re: [Fwd: callback and thread]



On Thu, 2 Nov 2000, DINH V. [iso-8859-1] Hoà wrote:

> "DINH V. Hoà" wrote:
> > 
> > I would like to know why I can't call a thread that modify a gtkwidget
> > in an callback function.
> > 
> > It hangs up as gdk_threads_enter is used.
> > 
> > Here the problem :
> > 
> > // main function :
> > 
> > gdk_threads_enter()
> > gtk_main()
> > gdk_threads_leave()
> > 
> > // callback :
> > 
> > phread_create(... thread_function ...)
> > 
> > // thread_function :
> > 
> > gdk_threads_enter()
> > // modify a widget
> > gdk_threads_leave()
> > 
> > When the program runs :
> > 
> > The call of gdk_thread_enter in the thread function hangs.
> > 
> > I think that the problem comes from the fact that 2 calls of
> > gdk_threads_enter
> > are likely to be nested ... but it is in a different thread. I would
> > like to
> > understand what is the exact problem and if a solution exists.

First of all, make sure you called g_thread_init() at the start of the
app.

Next, where are you calling gdk_threads_enter()?

The GDK lock is already acquired within signal handlers.  You should only
need to manually acquire it in timeout, idle and IO handlers.  If you are
attempting to acquire it inside a signal handler, then that would be your
problem.

James.





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