From 6003c80f7fe8bd5d1b8287e9e7126514b0d7e292 Mon Sep 17 00:00:00 2001 From: James Procter Date: Mon, 20 Mar 2023 15:28:33 +0000 Subject: [PATCH] JAL-4134 fix NPEs when matrix not resolved or alignment view is closed --- src/jalview/gui/AnnotationLabels.java | 2 +- src/jalview/gui/TreeCanvas.java | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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; -- 1.7.10.2