Merge branch 'bug/JAL-4242_exception_when_pressing_escape_in_fetch_from_URL_dialog...
[jalview.git] / src / jalview / bin / Commands.java
index 84effe0..d7d1ea3 100644 (file)
@@ -576,18 +576,24 @@ public class Commands
           }
           try
           {
+            long tries=1000;
+            while (sv.isBusy() && tries>0)
             {
-              while (sv.isBusy())
-                Thread.sleep(25);
+              Thread.sleep(25);
               if (sv.isBusy())
               {
+                tries--;
                 Console.debug(
                         "Waiting for viewer for " + structureFilepath);
               }
             }
+            if (tries==0 && sv.isBusy())
+            {
+              Console.warn("Gave up waiting for structure viewer to load. Something may have gone wrong.");
+            }
           } catch (Exception x)
           {
-
+            Console.warn("Exception whilst waiting for structure viewer "+structureFilepath,x);
           }
           Console.debug("Successfully opened viewer for "+structureFilepath);
           String structureImageFilename = ArgParser.getValueFromSubValOrArg(