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

Skip to content

Commit 2227aa3

Browse files
authored
Merge pull request #17101 from anntzer/wxclose
MNT: Avoid "wrapped C/C++ object has been deleted" when closing wx window.
2 parents 9daaa7d + 276c7ef commit 2227aa3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,9 @@ def show(self):
10581058
def destroy(self, *args):
10591059
# docstring inherited
10601060
_log.debug("%s - destroy()", type(self))
1061-
self.frame.Close()
1061+
frame = self.frame
1062+
if frame: # Else, may have been already deleted, e.g. when closing.
1063+
frame.Close()
10621064
wxapp = wx.GetApp()
10631065
if wxapp:
10641066
wxapp.Yield()

0 commit comments

Comments
 (0)