From 894a45573741b1b3a4a5d478499824ba653c3ae0 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 8 Aug 2017 11:18:12 +0100 Subject: [PATCH] JAL-2649 JAL-2650 wait for Conservation calc to complete before setting on new View coloured by Conservation --- src/jalview/viewmodel/AlignmentViewport.java | 14 ++++++++++++++ test/jalview/gui/AlignFrameTest.java | 14 +------------- 2 files changed, 15 insertions(+), 13 deletions(-) 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); -- 1.7.10.2