catch null pointer exception in headless context
[jalview.git] / src / jalview / gui / Desktop.java
index 0f6dbf4..1b24694 100755 (executable)
@@ -964,6 +964,12 @@ public class Desktop extends jalview.jbgui.GDesktop implements
   public static AlignmentPanel[] getAlignmentPanels(String viewId)
   {
     int count = 0;
+    if (Desktop.desktop==null)
+    {
+      // no frames created and in headless mode
+      // TODO: verify that frames are recoverable when in headless mode
+      return null;
+    }
     JInternalFrame[] frames = Desktop.desktop.getAllFrames();
     ArrayList aps = new ArrayList();
     for (int t = 0; t < frames.length; t++)