Skip to content

Commit

Permalink
Fix for issue matplotlib#17769
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tohc1 authored and MihaiAnton committed Mar 8, 2021
1 parent 059c478 commit e07f40b
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/matplotlib/backends/backend_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,7 @@ def _onClose(self, event):
_log.debug("%s - onClose()", type(self))
self.canvas.close_event()
self.canvas.stop_event_loop()
Gcf.destroy(self)
if self:
self.Destroy()
Gcf.destroy(self.figmgr)

def GetToolBar(self):
"""Override wxFrame::GetToolBar as we don't have managed toolbar"""
Expand All @@ -992,9 +990,6 @@ def Destroy(self, *args, **kwargs):
super().Destroy(*args, **kwargs)
if self.toolbar is not None:
self.toolbar.Destroy()
wxapp = wx.GetApp()
if wxapp:
wxapp.Yield()
return True


Expand Down Expand Up @@ -1043,10 +1038,7 @@ def destroy(self, *args):
_log.debug("%s - destroy()", type(self))
frame = self.frame
if frame: # Else, may have been already deleted, e.g. when closing.
frame.Close()
wxapp = wx.GetApp()
if wxapp:
wxapp.Yield()
frame.Destroy()

def full_screen_toggle(self):
# docstring inherited
Expand Down

0 comments on commit e07f40b

Please sign in to comment.