JAL-4077 JAL-3921 even more generous incremental backoff and warnings to log and...
authorJim Procter <jprocter@dundee.ac.uk>
Tue, 12 Nov 2024 15:36:44 +0000 (15:36 +0000)
committerJim Procter <jprocter@dundee.ac.uk>
Tue, 12 Nov 2024 15:36:44 +0000 (15:36 +0000)
src/jalview/gui/StructureViewerBase.java
src/jalview/project/Jalview2XML.java

index bd757e8..b8446cd 100644 (file)
@@ -1371,17 +1371,21 @@ public abstract class StructureViewerBase extends GStructureViewer
     {
       try
       {
-        Thread.sleep(5);
+        Thread.sleep(5+2*(51-wait));
       } catch (InterruptedException e)
       {
       }
       long nextl = session.length();
+      Console.trace("Finished waiting around for session save... ("+nextl+" length - was "+l+" and waits "+wait+")");
       if (nextl != l)
       {
         wait = 50;
         l = nextl;
       }
     } while (--wait > 0);
+    if (l==0) {
+      Console.error("Structure viewer session save resulted in zero length file. This is a bug, please report it.");
+    }
     return session;
   }
 
index e2a5508..afcd450 100644 (file)
@@ -1236,6 +1236,10 @@ public class Jalview2XML
               File viewerState = viewFrame.saveSession();
               if (viewerState != null)
               {
+                if (viewerState.length()==0)
+                {
+                  addErrorMessage("Dataloss warning: structure viewer session file was zero length.");
+                }
                 copyFileToJar(jout, viewerState.getPath(),
                         getViewerJarEntryName(viewId), viewerType);
               }
@@ -1891,6 +1895,15 @@ public class Jalview2XML
     return object;
   }
 
+  private void addErrorMessage(String string)
+  {
+    if (errorMessage==null)
+    {
+      errorMessage="";
+    }
+    errorMessage+=string+"\n";
+  }
+
   /**
    * Writes PCA viewer attributes and computed values to an XML model object and
    * adds it to the JalviewModel. Any exceptions are reported by logging.