From df8c5515d51b26ef229cd2916a30d6a27f46c236 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 6 Aug 2024 12:06:49 +0100 Subject: [PATCH] JAL-4446 avoid NPE when progress bar message is null --- src/jalview/gui/Desktop.java | 6 +++++- src/jalview/gui/ProgressBar.java | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) 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(); -- 1.7.10.2