X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FStructureViewerBase.java;h=ae2128bdb016298204c15e708c9efc24caf1a844;hb=36f083dc674297be2157d9f291a7cddba9d3250a;hp=4f746cbed4330f609ccbfb97d2b0ff804f29190e;hpb=8f08ed712138cea8987594a62b6053a0bfdba327;p=jalview.git diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 4f746cb..ae2128b 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -1156,12 +1156,14 @@ public abstract class StructureViewerBase extends GStructureViewer { if (afclient.isValidReference(pdbid)) { - pdbseq = afclient.getSequenceRecords(pdbid); + pdbseq = afclient.getSequenceRecords(pdbid,processingEntry.getRetrievalUrl()); } else { if (processingEntry.hasRetrievalUrl()) { + String safePDBId = java.net.URLEncoder.encode(pdbid,"UTF-8"); + // retrieve from URL to new local tmpfile - File tmpFile = File.createTempFile(pdbid, + File tmpFile = File.createTempFile(safePDBId, "." + (PDBEntry.Type.MMCIF.toString().equals( processingEntry.getType().toString()) ? "cif" : "pdb")); @@ -1210,8 +1212,23 @@ public abstract class StructureViewerBase extends GStructureViewer */ public File saveSession() { - // TODO: a wait loop to ensure the file is written fully before returning? - return getBinding() == null ? null : getBinding().saveSession(); + if (getBinding() == null) { return null;} + File session = getBinding().saveSession(); + long l = session.length(); + int wait=50; + do { + try { + Thread.sleep(5); + } catch (InterruptedException e) { + } + long nextl = session.length(); + if (nextl!=l) + { + wait = 50; + l=nextl; + } + } while (--wait>0); + return session; } /**