I know GTK APIs are not thread safe, I've an app with a thread doing a massive job that wants to update the gui status every few cycles, to do so I remembered an old post speaking about g_idle_add.
The question I have and which I didn't find answers both googling, both looking at the sources is if g_idle_add can be called without any extra mutex/lock from another thread. - I have to use gdk_threads_init() mechanism? - I have to use gdk_threads_enter/leave() around gtk_main() and around the g_idle_add call? - If so, if I use the gdk_threads_idle_add() facility I can avoid all the locks or I have to lock around gtk_main anyway? (the example doesn't clarify this) Ideally my code should be something like: static progress_datas; gint myfunc(vod *unused) { gtk_label_set_text(blablabla, progress_data); return FALSE; // call only once } work_thread() { while(1) { loops++; [... do the real work ...] if ((loops % 1000) == 0) { update_progress_datas(); g_idle_add(myfunc, NULL); } } } int main() { [..gui init and thread start] gtk_main() } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list