From e691bab6155dcc19e5d6ed552ba97138cd0c7b50 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 11 Feb 2021 11:30:20 +0000 Subject: [PATCH] JAL-3818 process Jmol callbacks in AWT thread --- src/jalview/ext/jmol/JalviewJmolBinding.java | 70 +++++++++++++++++--------- 1 file changed, 47 insertions(+), 23 deletions(-) diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index b2224ab..b0a7b0c 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -20,27 +20,6 @@ */ package jalview.ext.jmol; -import jalview.api.AlignmentViewPanel; -import jalview.api.FeatureRenderer; -import jalview.api.FeatureSettingsModelI; -import jalview.api.SequenceRenderer; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.HiddenColumns; -import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceI; -import jalview.gui.AppJmol; -import jalview.gui.IProgressIndicator; -import jalview.io.DataSourceType; -import jalview.io.StructureFile; -import jalview.schemes.ColourSchemeI; -import jalview.schemes.ResidueProperties; -import jalview.structure.AtomSpec; -import jalview.structure.StructureMappingcommandSet; -import jalview.structure.StructureSelectionManager; -import jalview.structures.models.AAStructureBindingModel; -import jalview.util.MessageManager; -import jalview.ws.dbsources.Pdb; - import java.awt.Color; import java.awt.Container; import java.awt.event.ComponentEvent; @@ -55,6 +34,8 @@ import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; +import javax.swing.SwingUtilities; + import org.jmol.adapter.smarter.SmarterJmolAdapter; import org.jmol.api.JmolAppConsoleInterface; import org.jmol.api.JmolSelectionListener; @@ -64,6 +45,27 @@ import org.jmol.c.CBK; import org.jmol.script.T; import org.jmol.viewer.Viewer; +import jalview.api.AlignmentViewPanel; +import jalview.api.FeatureRenderer; +import jalview.api.FeatureSettingsModelI; +import jalview.api.SequenceRenderer; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.HiddenColumns; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.gui.AppJmol; +import jalview.gui.IProgressIndicator; +import jalview.io.DataSourceType; +import jalview.io.StructureFile; +import jalview.schemes.ColourSchemeI; +import jalview.schemes.ResidueProperties; +import jalview.structure.AtomSpec; +import jalview.structure.StructureMappingcommandSet; +import jalview.structure.StructureSelectionManager; +import jalview.structures.models.AAStructureBindingModel; +import jalview.util.MessageManager; +import jalview.ws.dbsources.Pdb; + public abstract class JalviewJmolBinding extends AAStructureBindingModel implements JmolStatusListener, JmolSelectionListener, ComponentListener @@ -482,6 +484,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } Thread colourby = null; + /** * Sends a set of colour commands to the structure viewer * @@ -940,6 +943,28 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @Override public void notifyCallback(CBK type, Object[] data) { + /* + * ensure processed in AWT thread to avoid risk of deadlocks + */ + SwingUtilities.invokeLater(new Runnable() + { + + @Override + public void run() + { + processCallback(type, data); + } + }); + } + + /** + * Processes one callback notification from Jmol + * + * @param type + * @param data + */ + protected void processCallback(CBK type, Object[] data) + { try { switch (type) @@ -1106,8 +1131,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel // see JAL-623 - need method of matching pasted data up { pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe], - pdbfile, DataSourceType.PASTE, - getIProgressIndicator()); + pdbfile, DataSourceType.PASTE, getIProgressIndicator()); getPdbEntry(modelnum).setFile("INLINE" + pdb.getId()); matches = true; foundEntry = true; -- 1.7.10.2