Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f44c225

Browse files
authored
Merge pull request #22026 from anntzer/wxc
Simplify wxframe deletion.
2 parents d771226 + 0a36985 commit f44c225

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -937,24 +937,13 @@ def _on_close(self, event):
937937
self.figmgr.frame = None
938938
# remove figure manager from Gcf.figs
939939
Gcf.destroy(self.figmgr)
940+
try: # See issue 2941338.
941+
self.canvas.mpl_disconnect(self.canvas.toolbar._id_drag)
942+
except AttributeError: # If there's no toolbar.
943+
pass
940944
# Carry on with close event propagation, frame & children destruction
941945
event.Skip()
942946

943-
def Destroy(self, *args, **kwargs):
944-
try:
945-
self.canvas.mpl_disconnect(self.canvas.manager.toolbar._id_drag)
946-
# Rationale for line above: see issue 2941338.
947-
except AttributeError:
948-
pass # classic toolbar lacks the attribute
949-
# The "if self" check avoids a "wrapped C/C++ object has been deleted"
950-
# RuntimeError at exit with e.g.
951-
# MPLBACKEND=wxagg python -c 'from pylab import *; plot()'.
952-
if self and not self.IsBeingDeleted():
953-
super().Destroy(*args, **kwargs)
954-
# toolbar.Destroy() should not be necessary if the close event is
955-
# allowed to propagate.
956-
return True
957-
958947

959948
class FigureManagerWx(FigureManagerBase):
960949
"""

0 commit comments

Comments
 (0)