Hi,
I'm using a GenericDirCtrl as part of a customized file-open dialog. I used
the GetTreeCtrl method to access the TreeCtrl component, and then I bound
that object's EVT_TREE_SEL_CHANGED event so I could update various things in
the dialog based on the user's file/dir selection. All this works just fine.
However, I just spent some time struggling with the problem that as the
application is closing, a GenericDirCtrl's TreeCtrl can generate a
Sel-Changed event that arrives after the TreeCtrl has been deleted. This
problem has been encountered before, in
http://lists.wxwidgets.org/archive/wxPython-users/msg06376.html and
http://lists.wxwidgets.org/archive/wxPython-users/msg09517.html
Robin's answer in msg06376 is to use a flag to indicate that the app is
closing, and thereby avoid touching the already-deleted object. Another way
to avoid this is to Unbind() the EVT_TREE_SEL_CHANGED event handler in the
frame's EVT_CLOSE handler.
To see a simple example of this, you can access
http://www.kaarec.com/dgc_bug/Frame1.py and
http://www.kaarec.com/dgc_bug/App1.py (They are boa-generated, so a bit more
verbose than some prefer, but I've tried to boil it down to stone soup.)
I read Robin's explanation in msg06736 that this was an obscure problem with
a simple solution. But even though the solution is simple, finding it can be
painful. If someone could find a way to prevent TreeCtrl ghost-events, it
sure would be a lot better.
Env: winxp sp2, python 2.4.1, wx 2.6.1.0
-kaare