c++ - What is the best way to update a GTK interface in a multithreaded application? -


as understood, i'm doing way:

my main function launch threads before entering gtk main loop.

boost::thread p4(sensors_get_informations); gtk_main (); 

thoses threads stuff, , update corresponding element in interface.

void sensors_get_informations() {     while(!quit)     {        [...] //doing stuff        gdk_threads_add_idle((gsourcefunc)update_label_sensors, &str_end); //here interface updated        wait(1000);     } } 

and function wich update element (here it's label)

static bool update_label_sensors(....) {     [...]     gtk_label_set_label(gtk_label(label_sensors), label_string);     [...]     return false; } 

i have 5 threads working together, , seems work fine, usual way this, or there way improve ?

here present other method update on interface, research appears updating widget other threads main gtk thread sometime cause segmentation fault.

this usual way it. updating widgets other threads main gtk thread not allowed , cause program crash unpredictably.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -