Are there any suggestions/rules for how to clean up event handlers for
windows that disappear during the course of the application? I'm getting
buggy behaviour that could be because an event handler for a deleted window
is still active. Can this happen?
For example, if I create an wxTreeCtrl and set up an EVT_HELP handler, do I
need to disconnect that handler explicitly when the wxTreeCtrl is nuked (the
frame it was in is destroyed)? Right now, in situations I don't yet
understand, the EVT_HELP handler doesn't get called and the event heads up
the tree to hit some object in main, parent frame of the frame containing
the tree - popping up a completely out-of-context help message.
Are there any suggestions/rules for how to clean up event handlers for
windows that disappear during the course of the application? I'm getting
buggy behaviour that could be because an event handler for a deleted window
is still active. Can this happen?
For example, if I create an wxTreeCtrl and set up an EVT_HELP handler, do I
need to disconnect that handler explicitly when the wxTreeCtrl is nuked (the
frame it was in is destroyed)?
No, the event handler table is destroyed when the C++ window instance is destroyed. In the process the reference counts for the handler functions are decremented as well as the reference to the Python proxy object for the window.
In rare cases there can sometimes still be a message waiting for the window and it can cause problems when trying to deliver it to an instance that has been destroyed. If you suspect something like this then please provide a sample and we'll try to fix it.
ยทยทยท
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!