wxPython: wxEvtHandler leak on exit?

Ellers ellers at iinet.net.au
Fri Jun 21 02:19:10 EDT 2002


Hello all

I'm developing an app using wxPython (2.3.2) on win32, solaris and
linux. This particular problem doesn't appear on solaris/linux but on
win32 when I close all the frames (ie exit the app) I get this:

14:18:34: There were memory leaks.
14:18:34: ----- Memory dump -----
14:18:34: wxEvtHandler at $173F538, size 32
14:18:34: wxPyCallback at $173F478, size 12
14:18:34: wxObject at $173F428, size 28
14:18:34:
14:18:34:
14:18:34: ----- Memory statistics -----
14:18:34: 1 objects of class wxObject, total size 28
14:18:34: 1 objects of class wxPyCallback, total size 12
14:18:34: 1 objects of class wxEvtHandler, total size 32
14:18:34:
14:18:34: Number of object items: 3
14:18:34: Number of non-object items: 0
14:18:34: Total allocated size: 72
14:18:34:
14:18:34:

I have an event handler class that routes commands from a thread and
effectively does this:

	eventHandler = MyEventHandler( )

	class MyEventHandler( wxEvtHandler ):
	
		def __init__( self ):
			wxEvtHandler.__init__( self )
			EVT_MY_EVENT( self, self.OnMyEvent )
		
		def OnMyEvent( self, event ):
			exec event.code

And the event stuff is like this:

	wxEVT_MY_EVENT = wxNewEventType()

	def EVT_MY_EVENT(win, func):
		win.Connect(-1, -1, wxEVT_MY_EVENT, func)

	class MyEvent( wxPyEvent ):

		"""Allow the shell thread to post some code to be executed in the
main thread"""
			
		def __init__(self, code ):
			wxPyEvent.__init__(self)
			self.SetEventType(wxEVT_MY_EVENT)
			self.code = code


This works nicely 99% of the time.

However, when I send this command:

    wxPostEvent( eventHandler, MyEvent( "app.frame.Close( )))

The frame closes correctly but... somewhere in the process of shutting
down the app the above memory leak occurs.

I don't get it.

Any ideas?

Thanks 
Ellers



More information about the Python-list mailing list