JAL-4159 sometimes the progress bar may not be available - null check
authorJim Procter <jprocter@dundee.ac.uk>
Tue, 21 May 2024 17:15:11 +0000 (18:15 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Tue, 21 May 2024 17:15:11 +0000 (18:15 +0100)
src/jalview/gui/ProgressBar.java

index 8189313..73cd496 100644 (file)
@@ -24,6 +24,7 @@ import jalview.util.MessageManager;
 
 import java.awt.BorderLayout;
 import java.awt.Component;
+import java.awt.Container;
 import java.awt.GridLayout;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -272,10 +273,17 @@ public class ProgressBar implements IProgressIndicator
    */
   public JProgressBar getProgressBar(long id)
   {
-    for (Component component : progressBars.get(id).getComponents())
-    { 
+    Container progBar = progressBars.get(id);
+    if (progBar==null || progBar.getComponentCount()==0)
+    {
+      return null;
+    }
+    for (Component component : progBar.getComponents())
+    {
       if (component.getClass().equals(JProgressBar.class))
-       return (JProgressBar) component;
+      {
+        return (JProgressBar) component;
+      }
     }
     return null;
   }