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

Skip to content

Commit 276c7ef

Browse files
committed
Avoid "wrapped C/C++ object has been deleted" when closing wx window.
A RuntimeError is otherwise triggered when closing a wx window by clicking the "x" button on the top right. Bisects to bce6263 which fixed another issue with wx...
1 parent 065769b commit 276c7ef

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)