Gtk+ & Glib bug?? Threads....




Hello all...

     I wonder if someone can explain this rather strange behaviour from Gtk+
& Glib...

     I have a program that has a GTK window with a few buttons etc, one of
which calls some code that opens another connection to the X server (with
XLib calls) and displays an image in a window; at the moment this routine
show the image for a set amount of time and then destroys the window etc,
closes the connection to the X server (it's own one) and returns.

     So far so good, however I'd like the XLib code to start a seperate
thread to handle events from the X server etc. I thought I'd use glib's
gthread mutex's etc. So I've now compiled & linked all the code with the
'gthread' option for gtk-config.

     Now the strange behaviour - if I do g_thread_init() right at the start
of the application (along with XInitThreads) BEFORE gtk_init(), then on
returning from my 'show an image' (returning back into gtk_main) the
buttons' focus still follows the mouse and my GtkScrolledWindow still works,
but when I click a button the application suspends. This is still _exactly_
the same program as before - just with the g_thread_init() call added; I've
not yet actually written anything that uses threads or mutexs yet.

     If the call to g_thread_init() is placed AFTER gtk_init() then all
appears to be ok.

If it could possibly help (um....) then here what strace says when I click a
button....

poll(0x80da8d0, 0x2, 0xffffffff, 0x40021680, 0) = 1
ioctl(6, FIONREAD, [32])                = 0
read(6, "\5\1_\37\302\364\17\357%\0\0\0n\0"..., 32) = 32
write(6, "&\0\2\0%\0\0\0", 8)           = 8
read(6, 0xbfffe594, 32)                 = -1 EAGAIN (Resource temporarily
unavailable)
select(7, [6], NULL, NULL, NULL)        = 1 (in [6])
read(6, "\1\137\0\0\0\0%\0\0\0\322V\0\001"..., 32) = 32
uname({sys="Linux", node="cdw22", ...}) = 0
gettimeofday({931723736, 264412}, NULL) = 0
sigprocmask(SIG_SETMASK, NULL, [USR1])  = 0
sigsuspend([]

    Anyone have any ideas? Appologies for the rather cryptic explanation.
If no-one has a clue what I'm on about then I'll see if I can produce a
little program that exhibits the problem later this week.

    For now I'll leave g_thread_init() after gtk_init() and hope that it's
not just good luck that it works that way round for me! I'm bound to be
doing something 'evil' and plain wrong ;-]

Cheers...


Chris Wilson.

-=-

cdw22@cam.ac.uk

-=-



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