If you are using the version of Glib <=2.32 then apart from doing
gdk_threads_init you also need to do the following before doign
gdk_threads_init()
if (!g_thread_supported())
g_thread_init(NULL);
This will prevent deadlocks if GUI commands are passed from multiple
threads...
On Mon, Jan 14, 2013 at 9:21 AM, Phillip Susi <[email protected]> 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
> [email protected]
> https://mail.gnome.org/mailman/listinfo/gtk-list
>
_______________________________________________
gtk-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gtk-list