24 Nov 2005

python mysteries

Today I was tracking down a GtkUIManager warning we get in gedit new_mdi when you have two windows open and you close one

 GtkWarning: gtk_container_foreach: assertion `GTK_IS_CONTAINER (container)' failed 

so I take a look at uimanager’s code and see that it does the unmerging in an idle handler, and the idle handler was being run even after the window was gone. Since GtkUImanager properly cancels the idle when finalized, I said, ok, we forgot to unref the ui_manager in window_finalize!
And in fact we did… I add the unref and guess what: warning is still there. Stick a printf in finalize and discover that window_finalize never runs! Its refcount is bumped to the magical number 7. After a bit of fiddling I discover that the culprit are python plugins and in particular

 py_ret = PyObject_CallMethod (object->instance, method, "(N)", pygobject_new (G_OBJECT (window))); 

The refcount of GeditWindow in during gedit_window_destroy it’s always 7 no matter how many python plugins I load and at the moment, given how python ignorant I am, I have no clue how I am supposed to solve that… Dear Lazyweb, any suggestions?

Leave a Reply