Interesting. I don't get that, but I do get some random segfaults (I got lucky the first time I tested).
I'm awfully surprised that wx.GetApp() would return an iterator, as you are getting, so maybe it's corruption of some sort?
Reverting to revision 3441 on backend_wx.py does resolve this issue for me, so it is related to removing the wxapp global variable. While I like the idea of removing global variables, that was problematic, since when the wxapp variable is dereferenced, the whole wx.App is destructed, (hence, I believe the segfaults). Since I didn't want to just put the wxapp global variable back in, I assigned it to the figure that creates it, therefore stick around as long as the figure does. (Is that the correct thing for its lifetime?) Anyway, it seems to fix memleak_gui.py for me. Ken and Tim will probably want to check that I didn't cause more mainloops to start than necessary in the process.
Also, I'm a little puzzled by this code in show() in backend_wx.py:
wxapp = wx.GetApp()
if wxapp is not None:
# wxPython 2.4 has no wx.App.IsMainLoopRunning() method
imlr = getattr(wxapp, 'IsMainLoopRunning', lambda: False)
if imlr():
wxapp.MainLoop()
If I'm reading this correctly, shouldn't it be "if not imlr()"? If it is correct, maybe it needs a comment as to why mainloops should be started if a mainloop is already running.
Cheers,
Mike
Eric Firing wrote:
···
Mike,
New exception:
efiring@...340...:~/programs/py/mpl/tests$ python ../matplotlib_units/unit/memleak_gui.py -dwx -s1000 -e2000 > ~/temp/memleak_wx_0705.asc
Traceback (most recent call last):
File "../matplotlib_units/unit/memleak_gui.py", line 58, in <module>
pylab.close(fig)
File "/usr/local/lib/python2.5/site-packages/matplotlib/pylab.py", line 742, in close
_pylab_helpers.Gcf.destroy(manager.num)
File "/usr/local/lib/python2.5/site-packages/matplotlib/_pylab_helpers.py", line 28, in destroy
figManager.destroy()
File "/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_wx.py", line 1405, in destroy
self.frame.Destroy()
File "/usr/local/lib/python2.5/site-packages/matplotlib/backends/backend_wx.py", line 1364, in Destroy
wxapp.Yield()
AttributeError: 'listiterator' object has no attribute 'Yield'Eric