Re: Multithreaded gtk apps



just stop doing all of this.

ensure that there is only 1 thread making calls to GTK/GDK/X.

if other threads need to get graphical work done, use g_idle_add() or its cousins.

no locks, no questions about parallelism for any GUI stuff. really, this is what most of us are doing these days.


On Sun, Jan 13, 2013 at 10:51 PM, Phillip Susi <psusi ubuntu com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm having some trouble with a multithreaded gtk app ( gparted ) that
I'm hoping someone can help shed some light on.  From what I have
read, you have to call gdk_threads_init() before entering the main
loop, and then call gdk_threads_enter() in the background thread
before making gui calls, which I am ( and gdk_threads_leave() after ).

Now sometimes I see a deadlock and when I inspect via gdb, it appears
that the background thread is trying to show a dialog box which is
trying to emit a signal which is trying to invoke a closure, which I
think puts a message in the queue and waits for the main loop to
process it.  The main loop however, tries to acquire the gdk lock when
it wakes up ( I think? ), and so it blocks because the background
thread is holding it, and now you have deadlock.

I also sometimes get an Xlib assertion failure that seems to be
associated with gui calls in a non gui thread, but I am calling
gdk_enter_threads() before making gui calls in the background thread.
 So what's the deal?  What do you really have to do to have a
background thread issue a pop up message box?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ84CoAAoJEJrBOlT6nu75OLsIAMlnlYOSJ/Vr/bfOztVJqHaY
I+4IYVuhcCbNNzwzn98rc1nmCGFYisYjmotKxkGCWApuUGe9N1CTMUJVWxcWpuJV
sFzo+Tyc1X1EX/WzBmiOgo/BaZfEX0Ng59HtKDOylxKwTNc0kE0EjkM5vGdHWIpe
IG5SnncrtMhmQJGNlkbv98pwbNU9UXdaLmyCh3ScB+YrlRA88f4nskFi2UdxcIg/
p8wDcSnTQbLUW9PVmDoRRrDoywiRpbKCID6zny00SrScfowP0/PwWDwpUfDyVcQ4
n+BeGgCQAQWuUJC77V7UtA/suUo1StGFn9HQdLUONq4CKNVKkNIIR9c14d2rMCE=
=bg80
-----END PGP SIGNATURE-----
_______________________________________________
gtk-list mailing list
gtk-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-list



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