GApplication: leaves invalid instance as default after g_application_run() returns
I just got this in a test suite, so not the most standard usage (multiple apps, in different tests, in the same process..).
from gi.repository import Gio, GLib
app = Gio.Application()
app.register(None)
app.connect("activate", lambda *x: None)
GLib.idle_add(app.quit)
app.run()
# some different code in a different part of the app
default = Gio.Application.get_default()
if app.get_is_registered():
app.get_dbus_object_path() # segfaults
app.mark_busy() # segfaults
app.umark_busy() # segfaults
app.get_dbus_connection() # segfaults
g_application_run() frees things which makes the instance not usable after it returns, but other parts of the program might still access it via g_application_get_default()
Not sure what the right thing to do is here:
- unset the default app in run()? (<- seems like the easiest/robust fix to me)
- Unregister at the end of run?
- g_return_val_if_fail() everywhere?