Margarita Manterola wrote: > Hi! > > I've already submitted a bug, with the whole information about this, > but I'm writting also to the list to see if someone has any idea of > how to fix it. > > This is a problem with the C wrapper of gtk_window_list_toplevels for PyGTK. > > This is the reported bug: > http://bugzilla.gnome.org/show_bug.cgi?id=574259 (it has stacktraces > and the like) > > The problem is that in this code for _wrap_gtk_window_list_toplevels: > > static PyObject * > _wrap_gtk_window_list_toplevels(PyGObject *self) > { > GList *list, *tmp; > PyObject *py_list; > PyObject *gtk_obj; > > list = gtk_window_list_toplevels(); > > if ((py_list = PyList_New(0)) == NULL) { > g_list_free(list); > return NULL; > } > for (tmp = list; tmp != NULL; tmp = tmp->next) { > gtk_obj = pygobject_new(G_OBJECT(tmp->data)); > if (gtk_obj == NULL) { > g_list_free(list); > Py_DECREF(py_list); > return NULL; > } > PyList_Append(py_list, gtk_obj); > Py_DECREF(gtk_obj); > } > g_list_free(list); > return py_list; > } > > The garbage collector is called while the code is in the for loop, it > removes one of the toplevel windows which is not in use anywhere, > except that it's already on the list, thus after the GC returns and > the loop tries to access that removed window, it triggers a segfault. > > I can think of one ugly solution, but no correct solution. The ugly > solution would be to add extra checks everywhere, so that if a window > was destroyed in the middle of the function, everything would still > work. The correct solution would be to somehow prevent the GC from > destroying the unused window which is still in the list, but I have no > idea how. > > Any ideas on how to fix it?
For a rather brute-force hack, you can do this: import gtk, gobject import gc gc.disable() def collect(): with gtk.gdk.lock: gc.collect() return True gobject.timeout_add_seconds(10, collect) Not a long-term solution, but it gets your software working. -- Tim Evans Applied Research Associates NZ http://www.aranz.com/ _______________________________________________ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/