From d913da3552b4050d425eba551a50921efcc25f21 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 16 Dec 2022 13:21:17 +0000 Subject: [PATCH] JAL-4107 fix merge and avoid NPE --- src/jalview/gui/SeqCanvas.java | 2 +- src/jalview/ws/jws2/Jws2ClientFactory.java | 33 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 1137153..459f004 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -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; } diff --git a/src/jalview/ws/jws2/Jws2ClientFactory.java b/src/jalview/ws/jws2/Jws2ClientFactory.java index 4d78bd7..8a4f9fb 100644 --- a/src/jalview/ws/jws2/Jws2ClientFactory.java +++ b/src/jalview/ws/jws2/Jws2ClientFactory.java @@ -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 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 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); + } + } // ); + } } } } -- 1.7.10.2