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

Skip to content

Commit 443dd47

Browse files
committed
Avoid RuntimeError at wx exit.
1 parent fc413b3 commit 443dd47

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,10 @@ def Destroy(self, *args, **kwargs):
10801080
# Rationale for line above: see issue 2941338.
10811081
except AttributeError:
10821082
pass # classic toolbar lacks the attribute
1083-
if not self.IsBeingDeleted():
1083+
# The "if self" check avoids a "wrapped C/C++ object has been deleted"
1084+
# RuntimeError at exit with e.g.
1085+
# MPLBACKEND=wxagg python -c 'from pylab import *; plot()'.
1086+
if self and not self.IsBeingDeleted():
10841087
wx.Frame.Destroy(self, *args, **kwargs)
10851088
if self.toolbar is not None:
10861089
self.toolbar.Destroy()

0 commit comments

Comments
 (0)