Is there any tutorial on them? I searched the Web and did not find any good tutorial on GTK threads.
-- Sergei O. Naumov 26.11.2014, 12:41:16 пользователь Bernhard Schuster (schuster.bernh...@gmail.com) написал: You modify your label from a thread that is not the main/ui thread. Gtk+ is not threadsafe (few exceptions). Use g_idle_add/ g_timeout_add/ and friends (those are threadsafe) to implicitly serialize your ui modifications into the gtk mainloop. Do not use GDK_THREADS_ENTER/LEAVE foo unless you are maintaining a legacy codebase and you know exactly what this means including its implications. Best Bernhard On Nov 26, 2014 9:02 AM, "Sergei Naumov" <vo...@rambler.ru> wrote: Hi! I am writing an application that periodically reads data from network sockets (from Modbus enabled devices actually) and displays them in GTK+ application. I read some tutorials about GTK threads and created a separate thread that encompasses Modbus reads and updates to GTK labels: modbus_thread = g_thread_new ("update_from_modbus",update_from_modbus,NULL); The update_from_modbus() has a bunch of socket reads (inside xantrex_read_value()) and gtk_label_set_text() sprintf(params_val_text,"%-5.1f (%4.1f Hz)\n%-4.1f\n%-4d", 0.001*xantrex_read_value(modbus_pointer,0x004C,RECONSTRUCT_YES), 0.01*xantrex_read_value(modbus_pointer,0x004E,RECONSTRUCT_YES), 0.001*xantrex_read_value(modbus_pointer,0x0054,RECONSTRUCT_YES), xantrex_read_value(modbus_pointer,0x0052,RECONSTRUCT_YES)); gtk_label_set_text (GTK_LABEL(ac1_params_val),params_val_text); gtk_label_set_justify(GTK_LABEL(ac1_params_val),GTK_JUSTIFY_LEFT); However after several hours I see crashes when the program tries to reconnect to my device. I tried to enclose GTK operations into gtk_threads_enter() / gtk_threads_leave() but it has no effect. Can anyone, please explain what is wrong here or may be point to a good example of multithreaded GTK code which has network socket operations in it? Thanks in advance, -- Sergei _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list