Re: gtk and multithreading
- From: Ralph Walden <rwalden tripos com>
- To: gtk-list gnome org
- Subject: Re: gtk and multithreading
- Date: Tue, 14 Aug 2001 13:10:27 -0500
I had a similar problem using threads in a GTK application.
My problem was that my final gtk_main_quit would not end the
application. A window would not destroy itself after a destroy
signal until I moved the mouse over it.
I suppose it has to do with GTK not enjoying
multiple threads calling into GTK functions.
I solved my problem by making darn sure that my worker thread
made no GTK calls, just setting flags for the main thread to
act upon. I know that there are gdk functions for thread enter/exit,
but I don't understand how to use them.
Do you have to wrap EVERY call to any gtk/gdk API functions with the
thread enter/exit calls in a multi-threaded app?
Is there a threading FAQ for GTK?
Thanks all,
Ralph Walden
Brad House wrote:
>
> I've got a problem.
>
> The main program I have calls gtk_main()
> and everything works great until I get into threads.
>
> What I'm trying to do is call a thread to connect to a remote
> server. And when it recieves a response, it needs to pop up a
> window showing the response.
>
> Well anyhow it works for the most part...I'm using libglade
> so I'm doing a gtk_widget_show(widget); where the widget has
> already been referenced and hidden, etc. But the use of
> libglade should be most irrelevant.
>
> the only problem is that the widget won't display until I move
> the mouse...
>
> if I use gtk_widget_show_now(widget) instead it gives me an error
> about the main loop running in another thread, but again it displays
> properly as soon as I move the mouse.
>
> The only solution I can think of is to emit an event of some sort, and
> have the main loop capture the event and show the window for me instead
> of having my thread do it, but this is my first attempt at creating any
> GUI ... ever ... anywhere. So, the whole event structure is new to me
> (but I seem to have everything else besides threads down!)
>
> Also, I looked at the example in the FAQ, and it IS showing a redraw
> of a text field. So it seems as though a thread can update the GUI,
> so this really confuses me...maybe I'm not using the gdk_enter_thread()
> stuff properly....
>
> Any help would be much appreciated...thank you.
>
> -----------------------------
> Brad House
> Sr. Developer
> Main Street Softworks, Inc.
>
> brad mainstreetsoftworks com
> (352) 378-8228
> -----------------------------
>
> _______________________________________________
> gtk-list mailing list
> gtk-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtk-list
--
Ralph E. Walden
Tripos, Inc.
rwalden tripos com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]