Re: Application suddenly stuck at startup

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.

This works for me, at least.  You'll probably also need to do this in
other callbacks that do Gtk stuff.

That works for me also.
... I don't think there's any of those in the whole codebase of the application. Though.

An aside: in pyGTK, you could do
     with gtk.gdk.lock():
Is there something equivalent in the pyGI universe?

I haven't seen it, but that would be sweet!

N.B. This is all based on my incompletely understanding of GTK
threading.  If someone else says I'm wrong, they're likely right.



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