From: James Procter Date: Mon, 20 Mar 2023 15:28:33 +0000 (+0000) Subject: JAL-4134 fix NPEs when matrix not resolved or alignment view is closed X-Git-Tag: Release_2_11_3_0~15^2^2~8 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=6003c80f7fe8bd5d1b8287e9e7126514b0d7e292;p=jalview.git JAL-4134 fix NPEs when matrix not resolved or alignment view is closed --- diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index e002999..52a6066 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -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() diff --git a/src/jalview/gui/TreeCanvas.java b/src/jalview/gui/TreeCanvas.java index 98026da..cae2f31 100755 --- a/src/jalview/gui/TreeCanvas.java +++ b/src/jalview/gui/TreeCanvas.java @@ -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;