Re: strange segfault in threading



You don't need to poll: in your non-GUI thread you can call
g_idle_add, and the callback will be executed by the main GUI thread
'soon'.

Eg.:

 worker_fn() {
   for(;;) {
     void *stuff = g_malloc( .... );

     calculate_stuff( stuff );
     g_idle_add( update_with_stuff, stuff );
   }
 }

Then this will run from the GUI thread and can do any gtk:

 static gboolean update_with_stuff( viud *stuff ) {
   update_gui( stuff );
   g_free( stuff );
 }

I guess you might need something to stop the queue getting too big.

John

On 3/14/07, Luka Napotnik <luka napotnik gmail com> wrote:
I fixed this issue by making g_timeout() calls to a function that checks
a queue for requests to change the UI.



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