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

Skip to content

Commit cd41774

Browse files
authored
Merge pull request #15684 from anntzer/wxdeleted
Avoid RuntimeError at wx exit.
2 parents 1d6cc11 + 443dd47 commit cd41774

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
@@ -1050,7 +1050,10 @@ def Destroy(self, *args, **kwargs):
10501050
# Rationale for line above: see issue 2941338.
10511051
except AttributeError:
10521052
pass # classic toolbar lacks the attribute
1053-
if not self.IsBeingDeleted():
1053+
# The "if self" check avoids a "wrapped C/C++ object has been deleted"
1054+
# RuntimeError at exit with e.g.
1055+
# MPLBACKEND=wxagg python -c 'from pylab import *; plot()'.
1056+
if self and not self.IsBeingDeleted():
10541057
wx.Frame.Destroy(self, *args, **kwargs)
10551058
if self.toolbar is not None:
10561059
self.toolbar.Destroy()

0 commit comments

Comments
 (0)