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


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


def do_something():
    return True

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

    GLib.timeout_add(500, do_something)

    w = Gtk.Window()

    while Gtk.events_pending():

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

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 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 (?)



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