JAL-4134 fix NPEs when matrix not resolved or alignment view is closed
authorJames Procter <j.procter@dundee.ac.uk>
Mon, 20 Mar 2023 15:28:33 +0000 (15:28 +0000)
committerJames Procter <j.procter@dundee.ac.uk>
Mon, 20 Mar 2023 15:28:33 +0000 (15:28 +0000)
src/jalview/gui/AnnotationLabels.java
src/jalview/gui/TreeCanvas.java

index e002999..52a6066 100755 (executable)
@@ -428,7 +428,7 @@ public class AnnotationLabels extends JPanel
       {
         final PAEContactMatrix cm = (PAEContactMatrix) av
                 .getContactMatrix(aa[selectedRow]);
-        if (cm.getNewick()!=null && cm.getNewick().length()>0)
+        if (cm!=null && cm.getNewick()!=null && cm.getNewick().length()>0)
         {
           item = new JMenuItem("Show Tree for Matrix");
           item.addActionListener(new ActionListener()
index 98026da..cae2f31 100755 (executable)
@@ -1034,7 +1034,13 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
     {
       return false;
     }
+    if (av==null||av.getAlignment()==null)
+    {
+      // alignment is closed
+      return false;
+    }
     ColumnSelection cs = av.getColumnSelection();
+    
     HiddenColumns hc = av.getAlignment().getHiddenColumns();
     int offp = (rseq != null) ? rseq.findIndex(rseq.getStart() + colm)
             : colm;
@@ -1055,6 +1061,12 @@ public class TreeCanvas extends JPanel implements MouseListener, Runnable,
           Color col)
   {
     SequenceI rseq = tp.assocAnnotation.sequenceRef;
+    if (av==null||av.getAlignment()==null)
+    {
+      // alignment is closed
+      return;
+    }
+
     for (BinaryNode bn:l)
     {
       int colm=-1;