From 5d5f37b6e8fd725edf021045bac7ddc92392d68b Mon Sep 17 00:00:00 2001 From: "Robin Dunn (havok)" Date: Tue, 3 Jul 2012 12:13:19 -0700 Subject: [PATCH 1/2] wx 2.9 requires that all pushed EvtHandlers be popped before a window is destroyed. --- traitsui/wx/toolkit.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/traitsui/wx/toolkit.py b/traitsui/wx/toolkit.py index 2645fb197..3b29bad8a 100644 --- a/traitsui/wx/toolkit.py +++ b/traitsui/wx/toolkit.py @@ -471,6 +471,13 @@ def destroy_children ( self, control ): """ Destroys all of the child controls of a specified GUI toolkit control. """ + def _popAllEvtHandlers(win): + while win.GetEventHandler() is not win: + win.PopEventHandler(True) + for child in win.GetChildren(): + _popAllEvtHandlers(child) + + _popAllEvtHandlers(control) control.DestroyChildren() #--------------------------------------------------------------------------- From d8800b8be985ef17eb0d68ce86fa41a752e239af Mon Sep 17 00:00:00 2001 From: "Robin Dunn (cyclops)" Date: Wed, 24 Apr 2013 10:21:57 -0700 Subject: [PATCH 2/2] Also pop evthandlers in destroy_control --- traitsui/wx/toolkit.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/traitsui/wx/toolkit.py b/traitsui/wx/toolkit.py index 3b29bad8a..69f42c460 100644 --- a/traitsui/wx/toolkit.py +++ b/traitsui/wx/toolkit.py @@ -461,6 +461,7 @@ def skip_event ( self, event ): def destroy_control ( self, control ): """ Destroys a specified GUI toolkit control. """ + _popEventHandlers(control) control.Destroy() #--------------------------------------------------------------------------- @@ -471,13 +472,8 @@ def destroy_children ( self, control ): """ Destroys all of the child controls of a specified GUI toolkit control. """ - def _popAllEvtHandlers(win): - while win.GetEventHandler() is not win: - win.PopEventHandler(True) - for child in win.GetChildren(): - _popAllEvtHandlers(child) - - _popAllEvtHandlers(control) + for child in control.GetChildren(): + _popEventHandlers(child) control.DestroyChildren() #--------------------------------------------------------------------------- @@ -783,3 +779,13 @@ def _get_tab_hover_edge_bitmap ( self ): return image.create_image().ConvertToBitmap() + +#------------------------------------------------------------------------------- +def _popEventHandlers(ctrl): + """ Pop any event handlers that have been pushed on to a window and its + children. + """ + while ctrl is not ctrl.GetEventHandler(): + ctrl.PopEventHandler(True) + for child in ctrl.GetChildren(): + _popEventHandlers(child)