From 187c5bc17156035dd7fccadb516ea3a9628182ed Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Tue, 8 Dec 2015 15:18:52 -0800 Subject: [PATCH] Test if a frame is not already being deleted before trying to Destroy. fixes #3316 --- lib/matplotlib/backends/backend_wx.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index 25dc7fb10038..3291534b2022 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -1329,12 +1329,13 @@ def Destroy(self, *args, **kwargs): # Rationale for line above: see issue 2941338. except AttributeError: pass # classic toolbar lacks the attribute - wx.Frame.Destroy(self, *args, **kwargs) - if self.toolbar is not None: - self.toolbar.Destroy() - wxapp = wx.GetApp() - if wxapp: - wxapp.Yield() + if not self.IsBeingDeleted(): + wx.Frame.Destroy(self, *args, **kwargs) + if self.toolbar is not None: + self.toolbar.Destroy() + wxapp = wx.GetApp() + if wxapp: + wxapp.Yield() return True