From f676cbb3d859ce815e45524a1096a9f05eded23a Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 31 Aug 2016 16:16:06 +0100 Subject: [PATCH] JAL-2157 JAL-2154 simplify CanshowProducts code to avoid one source of NPE --- src/jalview/gui/AlignFrame.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index dd8fb7a..edfa928 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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 ptypes = (seqs == null || seqs.length == 0) ? null - : new CrossRef(seqs, dataset) - .findXrefSourcesForSequences(dna); + List ptypes = new CrossRef(seqs, dataset) + .findXrefSourcesForSequences(dna); for (final String source : ptypes) { -- 1.7.10.2