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

Skip to content

Commit 921a7ba

Browse files
committed
Merge pull request #5639 from RobinD42/issue3316-fix-wx-crash
Test if a frame is not already being deleted before trying to Destroy.
1 parent 896d089 commit 921a7ba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/matplotlib/backends/backend_wx.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,12 +1329,13 @@ def Destroy(self, *args, **kwargs):
13291329
# Rationale for line above: see issue 2941338.
13301330
except AttributeError:
13311331
pass # classic toolbar lacks the attribute
1332-
wx.Frame.Destroy(self, *args, **kwargs)
1333-
if self.toolbar is not None:
1334-
self.toolbar.Destroy()
1335-
wxapp = wx.GetApp()
1336-
if wxapp:
1337-
wxapp.Yield()
1332+
if not self.IsBeingDeleted():
1333+
wx.Frame.Destroy(self, *args, **kwargs)
1334+
if self.toolbar is not None:
1335+
self.toolbar.Destroy()
1336+
wxapp = wx.GetApp()
1337+
if wxapp:
1338+
wxapp.Yield()
13381339
return True
13391340

13401341

0 commit comments

Comments
 (0)