Re: Application suddenly stuck at startup



Suddenly yesterday, I couldn't run it anymore: when I start it, the
application initialization at the very beginning is alright, Gtk.Appliction
"activate" signal is triggered and answered as usual, and then, everything
hangs. *Something* get stuck *somewhere* and I can't run the application
anymore...

So...

I managed to make the application works again and get a very rough idea where the problem was.

I tentatively tried to produce a small use-case similar to what my application does, which triggers the same behavior:

===================================================
from gi.repository import Gtk, GLib, Gdk

Gdk.threads_init()
GLib.threads_init()

def do_something():
    print("foo")
    return True


def on_application_activate(app):
    if app.get_windows():
        print("Already launched")
        return

    GLib.timeout_add(500, do_something)

    w = Gtk.Window()
    w.set_application(app)
    #w.show()

    while Gtk.events_pending():
        Gtk.main_iteration()

app = Gtk.Application(application_id="test.gtk.StuckSomehow")
app.connect("activate", on_application_activate)
app.run([])
===================================================

Running this example as it on my computer displays the following problems:
  * the do_something() function is not called (it doesn't print "foo")
  * if you comment out the w.show() call, the window appears but can't
    be close.

I notice that either:
  * removing the loop with Gtk.main_iteration(), or...
  * removing the "Gdk.threads_init()" call
doesn't exhibit the problem.

I'm probably going to remove the call to .main_iteration() in my application but I don't think it's normal that everything stops like this, unless I'm clearly doing something wrong (?)

Regards,

 Jonathan


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