Xlib-error in threaded GTK+



I've read the FAQ, and I've done what it suggests, but I still can't
get rid of the "Xlib: unexpected async reply (sequence 0xXXXX)!".

I have a program, where I first have a part which uses no GTK+ or X
calls at all. In this first part, I create a thread, using
pthread_create(). This thread runs a function, in which I use GTK+. It
begins with:

  g_thread_init(NULL);
  gtk_init(&argc, &argv);
  gdk_threads_enter();

  gdk_rgb_init();

Later in this thread, I call gtk_main(). When this ends, from
gtk_main_quit(), I call gdk_threads_leave(), and then the thread
terminates.

Somewhere in gtk_main(), the above thread (the GTK+ one), will create
another thread, which never ever uses any GTK+ or X calls in itself.

The Xlib-error is seemingly random, so I can't reproduce it at a
specific point in the program.

I read somewhere that this error occurs when two threads are trying to 
call X functions at the same time, but this is not the case in my
program, because there is only one thread that actually uses GTK+/X. 

It's not a local error for me either, I've tried it in Linux on Sparc, 
PPC and Intel. 

Does anyone have any ideas what could cause this?


Greetings,

Tomas




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