Xlib, thread and gnome
- From: "Fernando Apesteguía" <fernando apesteguia gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Xlib, thread and gnome
- Date: Mon, 15 May 2006 16:34:05 +0200
That's a synchronization problem. I experimented something similar a few
time ago.
The problem with Xlib is because probably you are not returning from a
callback or you take too long to go back and return to gtk.
If you are attempting to access gtk widgets from other thread than the
"main" one, you should prevent other threads access with gdk_threads_enter
and gdk_threads_leave as you did for gtk_main()
For instance, if your secondary thread updates a gtk_label you should do:
gdk_threads_enter();
gtk_label_set_text(label, "text");
gdk_threads_enter();
Best regards.
PS: I'm not an expert at all... if I'm wrong, my apologies for all of the
list :)
---------- Forwarded message ----------
From: nik600 <nik600 gmail com>
Date: 15-may-2006 14:12
Subject: Xlib, thread and gnome
To: gtk-app-devel-list gnome org
hi
i am developing an application with gtk and thread.
I've received some Xlib: unexpected async reply errors and looking on
the web i've see that i must use this code:
int
main (int argc, char *argv[])
{
GtkWidget *window;
/* init threads */
g_thread_init(NULL);
gdk_threads_init();
/* init gtk */
gtk_init(&argc, &argv);
window = create_window();
gtk_widget_show(window);
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
return 0;
}
i've tried to add this code at my application but when i try to
execute it i get a segmentation fault error...
this is the reports of gdb:
Starting program:
/home/programmi/nik_stresser/nik_stresser/bin/nik_stresser_gtk
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 2739)]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 16384 (LWP 2739)]
0x40037a12 in pthread_mutex_lock () from /lib/libpthread.so.0
(gdb) bt
#0 0x40037a12 in pthread_mutex_lock () from /lib/libpthread.so.0
#1 0x40731cc5 in g_mem_chunk_new () from /usr/lib/libglib-2.0.so.0
#2 0x4071e809 in g_hash_table_size () from /usr/lib/libglib-2.0.so.0
#3 0x4071de12 in g_hash_table_insert () from /usr/lib/libglib-2.0.so.0
#4 0x40719073 in g_quark_to_string () from /usr/lib/libglib-2.0.so.0
#5 0x40718ec8 in g_quark_from_static_string () from /usr/lib/libglib-
2.0.so.0
#6 0x406f2b72 in g_type_init_with_debug_flags () from
/usr/lib/libgobject-2.0.so.0
#7 0x406f2d02 in g_type_init () from /usr/lib/libgobject-2.0.so.0
#8 0x405fb554 in gdk_pre_parse_libgtk_only () from /usr/lib/libgdk-
x11-2.0.so.0
#9 0x4042f6e3 in gtk_disable_setlocale () from /usr/lib/libgtk-x11-2.0.so.0
#10 0x4042f928 in gtk_disable_setlocale () from /usr/lib/libgtk-x11-2.0.so.0
#11 0x4073805b in g_option_context_parse () from /usr/lib/libglib-2.0.so.0
#12 0x4042fbce in gtk_parse_args () from /usr/lib/libgtk-x11-2.0.so.0
#13 0x4042fc06 in gtk_init_check () from /usr/lib/libgtk-x11-2.0.so.0
#14 0x4042fc56 in gtk_init () from /usr/lib/libgtk-x11-2.0.so.0
#15 0x0804cf5a in main (argc=1, argv=0xbffffa84) at
src/nik_stresser_gtk.c:336
(gdb)
can you help me please? where am i wrong? thanks nik
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]