problems with Gtk_Entry and threads




I'm having a strange problem and was wondering if perhaps someone could
perhaps shed some light on it.  I've got a dialog that contains a number
of different Gtk_Entry widgets (gtk--).

It's part of my fractal explorer.  A little while ago I broke it up into
two main threads, one to handle (almost) all the gtk stuff, and another to
handle the openGL rendering (into a Gtk_DrawingArea).  The threaded
interface seems to be working correctly (except for a strange occasional
race condition).  I'm not calling any gtk functions from my opengl thread. 
All I'm doing there that affects the dislplay is calling glXSwapBuffers,
which then draws into the drawing area. 

But for some strange reason whenever I try to type into any Gtk_Entry
everything freezes.  No errors or anything.  A stack dump from that point: 

(gdb) where
#0  0x40396924 in __syscall_sigsuspend ()
#1  0x403b9d44 in __DTOR_END__ ()
#2  0x40306a87 in __pthread_mutex_lock () at mutex.c:135
#3  0x4029dcf5 in _XLockDisplay ()
#4  0x402725f0 in XGetKeyboardMapping ()
#5  0x4027654c in _XKeyInitialize ()
#6  0x402768cc in _XTranslateKey ()
#7  0x40276c04 in _XLookupString ()
#8  0x402a4975 in XLookupString ()
#9  0x402c3979 in _XimLocalFilter ()
#10 0x4029d65c in XFilterEvent ()
#11 0x400e9557 in gdk_event_get () at gdk.c:714
#12 0x401381e1 in gtk_main_iteration_do () at gtkmain.c:754
#13 0x40138152 in gtk_main_iteration () at gtkmain.c:754
#14 0x40137fa1 in gtk_main () at gtkmain.c:754
#15 0x805e14a in main (argc=1, argv=0xbffff9b4)
    at /usr/local/include/gtk--/main.h:37

As far as I can tell, It's hanging on a lock somewhere in the X code.  If
I take out the call to XInitThreads() in main, I'm able to type into the
entries for a little while, but then I end up getting something like this:

Xlib: unexpected async reply (sequence 0x130d)!

Presumably when my gl thread calls glXSwapBuffers(), and then everything
starts to fall apart.  The gui is no longer responsive and the gl window
stops updating.  That's why we have XInitThreads(), right?

No other widgets act strangely.  I've ifdef'd all the threading stuff, and
when I compile without it everything works.  (no XInitThreads and no
threads either)

So why would XInitThreads cause the entry widget to bomb?

The main thread is the one that handles all the gtk stuff, so from gtk's
perspective there are no threads.  The opengl stuff is all rendered into a
seperate window from the text entries, so it seems like it shouldn't be a
problem with that.

I'm using gtk 1.0 and gtk-- 0.8.3 on RH 5.0 intel.

Thanks for any help.  

-Brian



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