fix for JAL-1016 - wait around until we have a complete set of PDB filename mappings...
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Sun, 7 Jul 2013 11:39:23 +0000 (12:39 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Sun, 7 Jul 2013 11:39:23 +0000 (12:39 +0100)
src/jalview/ext/jmol/JalviewJmolBinding.java

index 216c09e..4ac247c 100644 (file)
@@ -326,7 +326,39 @@ public abstract class JalviewJmolBinding implements StructureListener,
     assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
 
     String[] files = getPdbFile();
+    // check to see if we are still waiting for Jmol files
+    long starttime=System.currentTimeMillis();
+    boolean waiting=true;
+    do {
+      waiting=false;
+      for (String file:files)
+      {
+        try {
+          // HACK - in Jalview 2.8 this call may not be threadsafe so we catch
+          // every possible exception
+          StructureMapping[] sm = ssm.getMapping(file);
+          if (sm == null || sm.length == 0)
+          {
+            waiting = true;
+          }
+        } catch (Exception x)
+        {
+          waiting = true;
+        } catch (Error q)
+        {
+          waiting = true;
+        }
+      }
+      // we wait around for a reasonable time before we give up
+    } while (waiting && System.currentTimeMillis()<(10000+1000*files.length+starttime));
+    if (waiting)
+    {
+      System.err.println("RUNTIME PROBLEM: Jmol seems to be taking a long time to process all the structures.");
+      return;
+    }
     StringBuffer selectioncom = new StringBuffer();
+    
+
     // union of all aligned positions are collected together.
     for (int a = 0; a < _alignment.length; a++)
     {