JAL-2157 JAL-2154 simplify CanshowProducts code to avoid one source of NPE
authorJim Procter <jprocter@issues.jalview.org>
Wed, 31 Aug 2016 15:16:06 +0000 (16:16 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 31 Aug 2016 15:16:16 +0000 (16:16 +0100)
src/jalview/gui/AlignFrame.java

index dd8fb7a..edfa928 100644 (file)
@@ -4621,14 +4621,21 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   {
     SequenceI[] seqs = viewport.getAlignment().getSequencesArray();
     AlignmentI dataset = viewport.getAlignment().getDataset();
+
+    showProducts.removeAll();
+    final boolean dna = viewport.getAlignment().isNucleotide();
+
+    if (seqs == null || seqs.length == 0)
+    {
+      // nothing to see here.
+      return false;
+    }
+
     boolean showp = false;
     try
     {
-      showProducts.removeAll();
-      final boolean dna = viewport.getAlignment().isNucleotide();
-      List<String> ptypes = (seqs == null || seqs.length == 0) ? null
-              : new CrossRef(seqs, dataset)
-                      .findXrefSourcesForSequences(dna);
+      List<String> ptypes = new CrossRef(seqs, dataset)
+              .findXrefSourcesForSequences(dna);
 
       for (final String source : ptypes)
       {