Re: [Vala] why thread not updating the UI



Haven't tested your program but I have to say that you should never
update any UI stuff from the main thread unless you take preconditions
for it.
Gtk is thread aware but not thread save by default! You would have to
use 
Gdk.threads_enter() and Gdk.threads_leave() around Gtk.main() and every
UI access from a thread different from the main thread.
(For more information read documentation of Gdk.threads_enter() and
friends)

I strongly recommend handling the UI exclusively in the main thread !!
This will save you a lot of trouble. 

One thing you can do is calculating time intensive stuff in extra
threads and then return the result to the main thread using an idle
function like this:

void* gen_list(){ // thread function
    string[] data = {};
    data += "bla";
    //more ...
    Idle.add( () => { 
        // put ui stuff here, will be handled in the main thread
        foreach(string x in data) {
            TreeIter iter;
            liststore.append (out iter);
            liststore.set(iter,0,x);
        }
    });
}

Regards


Am Freitag, den 23.12.2011, 16:19 +0200 schrieb Dr. Amr Osman:
hello i made this small app to view icons from the system in python and
i am porting it to vala
but i can't get it to work any ideas what i am missing ?

_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list





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