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

Skip to content

Commit 6cbae5d

Browse files
committed
wx: Fix saving after window is closed.
We don't need to run `gui_repaint` if the window is gone, so just skip it.
1 parent 9a87327 commit 6cbae5d

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
@@ -623,7 +623,9 @@ def gui_repaint(self, drawDC=None, origin='WX'):
623623
The 'WXAgg' backend sets origin accordingly.
624624
"""
625625
_log.debug("%s - gui_repaint()", type(self))
626-
if self.IsShownOnScreen():
626+
# The "if self" check avoids a "wrapped C/C++ object has been deleted"
627+
# RuntimeError if doing things after window is closed.
628+
if self and self.IsShownOnScreen():
627629
if not drawDC:
628630
# not called from OnPaint use a ClientDC
629631
drawDC = wx.ClientDC(self)

0 commit comments

Comments
 (0)