File tree 1 file changed +4
-15
lines changed 1 file changed +4
-15
lines changed Original file line number Diff line number Diff line change @@ -937,24 +937,13 @@ def _on_close(self, event):
937
937
self .figmgr .frame = None
938
938
# remove figure manager from Gcf.figs
939
939
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
940
944
# Carry on with close event propagation, frame & children destruction
941
945
event .Skip ()
942
946
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
-
958
947
959
948
class FigureManagerWx (FigureManagerBase ):
960
949
"""
You can’t perform that action at this time.
0 commit comments