From: Jim Procter Date: Tue, 6 Aug 2024 11:06:49 +0000 (+0100) Subject: JAL-4446 avoid NPE when progress bar message is null X-Git-Tag: Release_2_11_4_0~14^2~6^2~11 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=df8c5515d51b26ef229cd2916a30d6a27f46c236;p=jalview.git JAL-4446 avoid NPE when progress bar message is null --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 394ef65..c1ad996 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -2939,7 +2939,11 @@ public class Desktop extends jalview.jbgui.GDesktop else { progressBars.put(Long.valueOf(id), addProgressPanel(message)); - progressBarMessages.put(id, message); + if (message!=null) { + progressBarMessages.put(id, message); + } else { + progressBarMessages.remove(id); + } } } diff --git a/src/jalview/gui/ProgressBar.java b/src/jalview/gui/ProgressBar.java index e6ee641..37a4b94 100644 --- a/src/jalview/gui/ProgressBar.java +++ b/src/jalview/gui/ProgressBar.java @@ -157,13 +157,13 @@ public class ProgressBar implements IProgressIndicator JProgressBar progressBar = new JProgressBar(); progressBar.setIndeterminate(true); - progressPanel.add(new JLabel(message), BorderLayout.WEST); + progressPanel.add(new JLabel(message==null ? "" : message), BorderLayout.WEST); progressPanel.add(progressBar, BorderLayout.CENTER); addRow(progressPanel); progressBars.put(id, progressPanel); - progressBarMessages.put(id, message); + progressBarMessages.put(id, message == null ? "" : message); } refreshLayout();