Segfault/TypeError in Gtk.window_list_toplevels()
A segfault can happen when calling Gtk.window_list_toplevels
, when converting GList
to a Python list. Sometimes, TypeError
is raised about no means to translate argument or return value.
It seems that the error is caused by Python GC running while PyGObject is iterating over the GList
and creating Python objects. This can sometimes cause that windows in the list are already destroyed and deallocated. In that case, trying to create a PyGObject wrapper for that window can either segfault or end up with a TypeError
in pygi_arg_gobject_to_py
.
In PyGTK (the old one for GTK 2, if someone still remembers g_object_ref
on all objects in the list before converting it to a Python list and calling g_object_unref
after.
See https://bugzilla.gnome.org/show_bug.cgi?id=574259 for more details about the bug in PyGTK.
GTK version: 3.24.34
PyGObject version: 3.42.2