From ef803646ff93ba08ee9fe10300a043f79fdbee66 Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauld.mccarthy@gmail.com>
Date: Mon, 7 Jul 2014 14:01:57 +0100
Subject: [PATCH] Fix attempt to detach deleted view config panel from AUI
 manager (which was causing exceptions and segfault on exit).

---
 fsl/fslview/fslviewframe.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/fsl/fslview/fslviewframe.py b/fsl/fslview/fslviewframe.py
index 06bd9d252..bb7ab3f30 100644
--- a/fsl/fslview/fslviewframe.py
+++ b/fsl/fslview/fslviewframe.py
@@ -170,6 +170,14 @@ class FSLViewFrame(wx.Frame):
 
         def onViewPanelDestroy(ev):
             ev.Skip()
+
+            # if the config panel has already been closed, it
+            # will have been replaced with a python wrapper
+            # around a deleted C++ object. When converted to
+            # boolean, this wrapper will evaluate to False.
+            if not confPanel:
+                return
+            
             self._auimgr.DetachPane(confPanel)
             self._auimgr.Update()
             confPanel.Destroy()
-- 
GitLab