From 04cefeebe4d5267638319c74fe68b8b9cc0bf37a Mon Sep 17 00:00:00 2001 From: James Procter Date: Thu, 2 Nov 2023 19:43:01 +0000 Subject: [PATCH] JAL-4217 wrap progress bar creation in an invokeLater to avoid setFont deadlock with other ops --- src/jalview/bin/Commands.java | 58 ++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index a092cd6..2794b02 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -196,7 +196,7 @@ public class Commands if (avm.containsArg(Arg.APPEND) || avm.containsArg(Arg.OPEN)) { commandArgsProvided = true; - long progress = -1; + final long progress = System.currentTimeMillis(); boolean first = true; boolean progressBarSet = false; @@ -222,10 +222,18 @@ public class Commands first = false; if (!headless && desktop != null) { - desktop.setProgressBar( - MessageManager.getString( - "status.processing_commandline_args"), - progress = System.currentTimeMillis()); + SwingUtilities.invokeLater(new Runnable() + { + @Override + public void run() + { + desktop.setProgressBar( + MessageManager.getString( + "status.processing_commandline_args"), + progress); + + } + }); progressBarSet = true; } } @@ -363,25 +371,27 @@ public class Commands } } - // Show secondary structure annotations? boolean showSSAnnotations = avm.getFromSubValArgOrPref( Arg.SHOWSSANNOTATIONS, av.getSubVals(), null, "STRUCT_FROM_PDB", true); - + // Show sequence annotations? boolean showAnnotations = avm.getFromSubValArgOrPref( Arg.SHOWANNOTATIONS, av.getSubVals(), null, "SHOW_ANNOTATIONS", true); - + boolean hideTFrows = (avm.getBoolean(Arg.NOTEMPFAC)); final AlignFrame _af = af; - // many of jalview's format/layout methods are only thread safe on the swingworker thread. - // all these methods should be on the alignViewController so it can coordinate such details + // many of jalview's format/layout methods are only thread safe on the + // swingworker thread. + // all these methods should be on the alignViewController so it can + // coordinate such details try { SwingUtilities.invokeAndWait(new Runnable() { + @Override public void run() { @@ -433,9 +443,11 @@ public class Commands { Console.debug( "Opening '" + openFile + "' in existing alignment frame"); + DataSourceType dst = HttpUtils.startsWithHttpOrHttps(openFile) ? DataSourceType.URL : DataSourceType.FILE; + FileLoader fileLoader = new FileLoader(!headless); fileLoader.LoadFile(af.getCurrentView(), openFile, dst, null, false); @@ -464,11 +476,14 @@ public class Commands // open the structure (from same PDB file or given PDBfile) if (!avm.getBoolean(Arg.NOSTRUCTURE)) { + AlignFrame af = afMap.get(id); if (avm.containsArg(Arg.STRUCTURE)) { commandArgsProvided = true; - for (ArgValue av : avm.getArgValueList(Arg.STRUCTURE)) + for ( + + ArgValue av : avm.getArgValueList(Arg.STRUCTURE)) { argParser.setStructureFilename(null); String val = av.getValue(); @@ -835,6 +850,7 @@ public class Commands if (wrap) { + AlignFrame af = afMap.get(id); if (af != null) { @@ -846,16 +862,16 @@ public class Commands boolean doShading = avm.getBoolean(Arg.TEMPFAC_SHADING); if (doShading) { - AlignFrame af = afMap.get(id); - for (AlignmentAnnotation aa : af.alignPanel.getAlignment() - .findAnnotation(PDBChain.class.getName().toString())) - { - AnnotationColourGradient acg = new AnnotationColourGradient(aa, - af.alignPanel.av.getGlobalColourScheme(), 0); - acg.setSeqAssociated(true); - af.changeColour(acg); - Console.info("Changed colour " + acg.toString()); - } + AlignFrame af = afMap.get(id); + for (AlignmentAnnotation aa : af.alignPanel.getAlignment() + .findAnnotation(PDBChain.class.getName().toString())) + { + AnnotationColourGradient acg = new AnnotationColourGradient(aa, + af.alignPanel.av.getGlobalColourScheme(), 0); + acg.setSeqAssociated(true); + af.changeColour(acg); + Console.info("Changed colour " + acg.toString()); + } } */ -- 1.7.10.2