Skip to content

Commit d165b0a

Browse files
committed
Fix for issue matplotlib#17769
1) On figure window (FigureFrameWx) close - remove figure manager from from Gcf class previously Gcf.destroy was called with FigureFrameWx not FigureManagerWx instance so figure was not removed. 2) Destroy now done from FigureManagerWx.destroy() method to prevent multiple calls to the close event handler. 3) Remove unneeded wx mainloop yield calls that cause crash on windows form both FigureManagerWx.destroy and FigureFrameWx.Destroy
1 parent 6ddad42 commit d165b0a

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -971,9 +971,7 @@ def _onClose(self, event):
971971
_log.debug("%s - onClose()", type(self))
972972
self.canvas.close_event()
973973
self.canvas.stop_event_loop()
974-
Gcf.destroy(self)
975-
if self:
976-
self.Destroy()
974+
Gcf.destroy(self.figmgr)
977975

978976
def GetToolBar(self):
979977
"""Override wxFrame::GetToolBar as we don't have managed toolbar"""
@@ -992,9 +990,6 @@ def Destroy(self, *args, **kwargs):
992990
super().Destroy(*args, **kwargs)
993991
if self.toolbar is not None:
994992
self.toolbar.Destroy()
995-
wxapp = wx.GetApp()
996-
if wxapp:
997-
wxapp.Yield()
998993
return True
999994

1000995

@@ -1043,10 +1038,7 @@ def destroy(self, *args):
10431038
_log.debug("%s - destroy()", type(self))
10441039
frame = self.frame
10451040
if frame: # Else, may have been already deleted, e.g. when closing.
1046-
frame.Close()
1047-
wxapp = wx.GetApp()
1048-
if wxapp:
1049-
wxapp.Yield()
1041+
frame.Destroy()
10501042

10511043
def full_screen_toggle(self):
10521044
# docstring inherited

0 commit comments

Comments
 (0)