JAL-2649 JAL-2650 wait for Conservation calc to complete before setting
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 8 Aug 2017 10:18:12 +0000 (11:18 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Tue, 8 Aug 2017 10:18:12 +0000 (11:18 +0100)
on new View coloured by Conservation

src/jalview/viewmodel/AlignmentViewport.java
test/jalview/gui/AlignFrameTest.java

index 5a7a27f..70f16d9 100644 (file)
@@ -641,6 +641,20 @@ public abstract class AlignmentViewport implements AlignViewportI,
     {
       if (getConservationSelected())
       {
+        int retry = 0;
+        synchronized (this)
+        {
+          while (isCalcInProgress() && retry < 10)
+          {
+            try
+            {
+              wait(50);
+              retry++;
+            } catch (InterruptedException e)
+            {
+            }
+          }
+        }
         residueShading.setConservation(hconservation);
       }
       residueShading.alignmentChanged(alignment, hiddenRepSequences);
index 1d8b240..af9c045 100644 (file)
@@ -26,7 +26,6 @@ import static org.testng.Assert.assertNotSame;
 import static org.testng.Assert.assertSame;
 import static org.testng.Assert.assertTrue;
 
-import jalview.api.AlignCalcManagerI;
 import jalview.bin.Cache;
 import jalview.bin.Jalview;
 import jalview.datamodel.Alignment;
@@ -539,24 +538,13 @@ public class AlignFrameTest
             new String[] { "Background" }));
 
     /*
-     * make a new View, wait for Conservation thread to complete,
-     * verify alignment and group colour schemes
+     * make a new View, verify alignment and group colour schemes
      */
     af.newView_actionPerformed(null);
     assertEquals(af.alignPanel.getViewName(), "View 1");
     AlignViewport av2 = af.getViewport();
     assertNotSame(av, av2);
     assertSame(av2, af.alignPanel.av);
-    AlignCalcManagerI calcManager = av2.getCalcManager();
-    do
-    {
-      try
-      {
-        Thread.sleep(50);
-      } catch (InterruptedException x)
-      {
-      }
-    } while (calcManager.isWorking());
     rs = av2.getResidueShading();
     assertNotSame(av.getResidueShading(), rs);
     assertEquals(rs.getThreshold(), 10);