JAL-2899 asynchronous Jmol colour updates bug/JAL-2899
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 2 Feb 2018 14:23:21 +0000 (14:23 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Fri, 2 Feb 2018 14:23:21 +0000 (14:23 +0000)
src/jalview/ext/jmol/JalviewJmolBinding.java

index 41bc116..bbb75cf 100644 (file)
@@ -52,6 +52,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.Vector;
 
+import javax.swing.SwingUtilities;
+
 import org.jmol.adapter.smarter.SmarterJmolAdapter;
 import org.jmol.api.JmolAppConsoleInterface;
 import org.jmol.api.JmolSelectionListener;
@@ -485,15 +487,22 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel
    */
   @Override
   protected void colourBySequence(
-          StructureMappingcommandSet[] colourBySequenceCommands)
+          final StructureMappingcommandSet[] colourBySequenceCommands)
   {
-    for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
+    SwingUtilities.invokeLater(new Runnable()
     {
-      for (String cbyseq : cpdbbyseq.commands)
+      @Override
+      public void run()
       {
-        executeWhenReady(cbyseq);
+        for (StructureMappingcommandSet cpdbbyseq : colourBySequenceCommands)
+        {
+          for (String cbyseq : cpdbbyseq.commands)
+          {
+            executeWhenReady(cbyseq);
+          }
+        }
       }
-    }
+    });
   }
 
   /**