JAL-3187 JAL-2764 close feature settings when parent align frame is closed (need...
authorJim Procter <jprocter@issues.jalview.org>
Wed, 19 Feb 2020 15:03:44 +0000 (15:03 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 19 Feb 2020 15:03:44 +0000 (15:03 +0000)
src/jalview/gui/AlignFrame.java
src/jalview/gui/Desktop.java

index 0297a74..de82fd8 100644 (file)
@@ -1479,9 +1479,13 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
           closeView(alignPanel);
         }
       }
-
       if (closeAllTabs)
       {
+        if (featureSettings != null && featureSettings.isOpen())
+        {
+          featureSettings.close();
+          featureSettings = null;
+        }
         /*
          * this will raise an INTERNAL_FRAME_CLOSED event and this method will
          * be called recursively, with the frame now in 'closed' state
index ed9ed50..1b8dda7 100644 (file)
@@ -1924,7 +1924,10 @@ public class Desktop extends jalview.jbgui.GDesktop
     }
 
     // FIXME: ideally should use UI interface API
-    FeatureSettings viewFeatureSettings = af.featureSettings;
+    FeatureSettings viewFeatureSettings = (af.featureSettings != null
+            && af.featureSettings.isOpen())
+            ? af.featureSettings
+            : null;
     Rectangle fsBounds = af.getFeatureSettingsGeometry();
     for (int i = 0; i < size; i++)
     {
@@ -1935,9 +1938,10 @@ public class Desktop extends jalview.jbgui.GDesktop
       // transfer reference for existing feature settings to new alignFrame
       if (ap == af.alignPanel)
       {
-        newaf.featureSettings = (viewFeatureSettings.fr.ap == ap)
-                ? viewFeatureSettings
-                : null;
+        if (viewFeatureSettings != null && viewFeatureSettings.fr.ap == ap)
+        {
+          newaf.featureSettings = viewFeatureSettings;
+        }
         newaf.setFeatureSettingsGeometry(fsBounds);
       }
 
@@ -1966,6 +1970,7 @@ public class Desktop extends jalview.jbgui.GDesktop
       }
     }
 
+    af.featureSettings = null;
     af.alignPanels.clear();
     af.closeMenuItem_actionPerformed(true);