From: gmungoc Date: Tue, 8 Aug 2017 10:18:12 +0000 (+0100) Subject: JAL-2649 JAL-2650 wait for Conservation calc to complete before setting X-Git-Tag: Release_2_10_3b1~132^2~13 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=894a45573741b1b3a4a5d478499824ba653c3ae0;p=jalview.git JAL-2649 JAL-2650 wait for Conservation calc to complete before setting on new View coloured by Conservation --- diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 5a7a27f..70f16d9 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -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); diff --git a/test/jalview/gui/AlignFrameTest.java b/test/jalview/gui/AlignFrameTest.java index 1d8b240..af9c045 100644 --- a/test/jalview/gui/AlignFrameTest.java +++ b/test/jalview/gui/AlignFrameTest.java @@ -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);