JAL-4107 fix merge and avoid NPE
authorJim Procter <j.procter@dundee.ac.uk>
Fri, 16 Dec 2022 13:21:17 +0000 (13:21 +0000)
committerJim Procter <j.procter@dundee.ac.uk>
Fri, 16 Dec 2022 13:21:17 +0000 (13:21 +0000)
src/jalview/gui/SeqCanvas.java
src/jalview/ws/jws2/Jws2ClientFactory.java

index 1137153..459f004 100755 (executable)
@@ -377,7 +377,7 @@ public class SeqCanvas extends JPanel implements ViewportListenerI
   @Override
   public void paintComponent(Graphics g)
   {
-    if (av.getAlignPanel().getHoldRepaint())
+    if (av==null || av.getAlignPanel()==null || av.getAlignPanel().getHoldRepaint())
     {
       return;
     }
index 4d78bd7..8a4f9fb 100644 (file)
@@ -1,5 +1,6 @@
 package jalview.ws.jws2;
 
+import jalview.api.AlignCalcManagerI2;
 import jalview.api.AlignCalcWorkerI;
 import jalview.bin.Cache;
 import jalview.bin.Console;
@@ -51,24 +52,28 @@ public class Jws2ClientFactory
     // is there an aaCon worker already present - if so, set it to use the
     // given service handle
     {
-      List<AlignCalcWorkerI> aaconClient = alignFrame.getViewport()
-              .getCalcManager()
-              .getWorkersOfClass(aaui.getClient());
-      if (aaconClient != null && aaconClient.size() > 0)
+      AlignCalcManagerI2 mger = alignFrame.getViewport()
+              .getCalcManager();
+      if (mger != null)
       {
-        SeqAnnotationServiceCalcWorker worker = (SeqAnnotationServiceCalcWorker) aaconClient
-                .get(0);
-        if (!worker.service.getHostURL().equals(service.getHostURL()))
+        List<AlignCalcWorkerI> aaconClient = mger
+                .getWorkersOfClass(aaui.getClient());
+        if (aaconClient != null && aaconClient.size() > 0)
         {
-          // javax.swing.SwingUtilities.invokeLater(new Runnable()
+          SeqAnnotationServiceCalcWorker worker = (SeqAnnotationServiceCalcWorker) aaconClient
+                  .get(0);
+          if (!worker.service.getHostURL().equals(service.getHostURL()))
           {
-            // @Override
-            // public void run()
+            // javax.swing.SwingUtilities.invokeLater(new Runnable()
             {
-              removeCurrentAAConWorkerFor(aaui, alignFrame);
-              buildCurrentAAConWorkerFor(aaui, alignFrame, service);
-            }
-          } // );
+              // @Override
+              // public void run()
+              {
+                removeCurrentAAConWorkerFor(aaui, alignFrame);
+                buildCurrentAAConWorkerFor(aaui, alignFrame, service);
+              }
+            } // );
+          }
         }
       }
     }