Re: Threads troubles. and events



In message <01122602055601 01352 Telemaco>you write:
>I'm working on gtk using gthreads., but I have a little trouble.
>
>In a random time, a thread  needs update a widget(it draws a rectagle in a 
>pixmap "gdk_draw_rectangle" and puts the rectangle in the widget draw queue 
>"gtk_widget_queue_draw_area"), it seems work ok, but isn't it . After a lot 
>of calls to this function.  the widget seems stop your work. and some other 
>child widgets disapear  from the widget (are not drawn). 
>The widget  is indeed running, it does all event callbacks ok. but the draw 
>event queue seems broken. All redraw functions not works.
>
>I think is a something about draw events queue, but I unknown how the main 
>event loop works and how can I fix it. 
>
>I can solve this by setting a shared variable and a timeout 
>(g_timeout_add/gtk_timeout_add) in the gtk_main thread, every X time , read 
>this variable , if changes, update . But it will introduce a lot of unneeded 
>overhead. to the gtk_main loop.  I prefer do update acction from the other 
>thread.
>
>Can I do it?
>Can I put form another thread an update area using 
>"gtk_widget_queue_draw_area", ?

please read the FAQ entry on using threads. the FAQ can be found at
www.gtk.org. the short story is that you must either use explicit
locks if multiple threads call glib or gtk or gdk functions, or you
must ensure that only one thread ever does so.

--p



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