Re: Multithreaded gtk apps
- From: Emmanuele Bassi <ebassi gmail com>
- To: Phillip Susi <psusi ubuntu com>
- Cc: ML-gtk <gtk-list gnome org>
- Subject: Re: Multithreaded gtk apps
- Date: Mon, 14 Jan 2013 15:02:24 +0000
hi;
On 14 January 2013 14:53, Phillip Susi <psusi ubuntu com> wrote:
> So the official documentation is wrong?
the documentation says:
GTK+ is "thread aware" but not thread safe — it provides a global lock
controlled by gdk_threads_enter()/gdk_threads_leave() which protects
all use of GTK+. That is, only one thread can use GTK+ at any given
time.
You must call gdk_threads_init() before executing any other GTK+ or
GDK functions in a threaded GTK+ program.
[...]
Unfortunately, all of the above documentation holds with the X11
backend only. With the Win32 backend, GDK and GTK+ calls should
not be attempted from multiple threads at all. Combining the GDK lock
with other locks such as the Python global interpreter lock can be
complicated.
-- http://developer.gnome.org/gdk3/stable/gdk3-Threads.html
furthermore, gdk_threads_enter() and gdk_threads_leave() have been
deprecated since GTK+ 3.6.
> I need to return the results of the dialog box so an idle won't work
> for me.
you can raise the dialog from the main thread, and use a condition and
a shared variable to notify the thread with the user-supplied value.
the important thing is that you cannot call GTK functions from a
thread other than the one that called gtk_init()/gtk_main().
ciao,
Emmanuele.
--
W: http://www.emmanuelebassi.name
B: http://blogs.gnome.org/ebassi/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]