Re: Application suddenly stuck at startup

On Fri, Mar 1, 2013 at 12:46 PM, Jonathan Ballet <jon multani info> wrote:
On 03/01/2013 03:11 PM, Robert Schroll wrote:
On Fri, Mar 1, 2013 at 10:12 AM, Jonathan Ballet <jon multani info> wrote:
I notice that either:
  * removing the loop with Gtk.main_iteration(), or...
  * removing the "Gdk.threads_init()" call
doesn't exhibit the problem.

I think the problem is that you don't have the Gdk lock when you're
calling Gtk.main_iteration, which is a bad thing.  If you take out
Gdk.threads_init, the main thread will never give up the lock, so your callback will be guaranteed to run inside of it. If you don't need to
do Gtk stuff from other threads, this is probably the way to go.

As I understand [1], I don't have to call Gdk.threads_enter() / Gdk.threads_leave() if I'm within a signal handler, such as the one from my example I would say.

I agree with your reading of the docs.  It's things like this that leave me perpetually confused about threading.  The one possible explanation I see is that "activate" is a signal of GApplication, not GtkApplication.  It could be that GLib signal handlers run outside of the Gdk lock, while Gtk signal handlers run inside.

Hopefully someone who actually understands all of this will comment.


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