File tree Expand file tree Collapse file tree 1 file changed +4
-15
lines changed
Expand file tree Collapse file tree 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):
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
959948class FigureManagerWx (FigureManagerBase ):
960949 """
You can’t perform that action at this time.
0 commit comments