From: jprocter Date: Mon, 1 Oct 2012 09:56:21 +0000 (+0100) Subject: JAL-1184 apparent deadlock when launching jalview on w7 - attempt to patch X-Git-Tag: Jalview_2_9~282 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=cb03edaa1450e5716bd37ca5cc430a46c245e9db;p=jalview.git JAL-1184 apparent deadlock when launching jalview on w7 - attempt to patch --- diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index d1e8b6a..50f0095 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -59,6 +59,7 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.util.ArrayList; import java.util.Hashtable; @@ -2616,19 +2617,27 @@ public class Desktop extends jalview.jbgui.GDesktop implements /** * single thread that handles display of dialogs to user. */ - ExecutorService dialogExecutor=null; + ExecutorService dialogExecutor=Executors.newSingleThreadExecutor(); /** * add another dialog thread to the queue * @param prompter */ - public synchronized void addDialogThread(Runnable prompter) + public void addDialogThread(final Runnable prompter) { - if (dialogExecutor==null) + dialogExecutor.submit(new Runnable() { - dialogExecutor = Executors.newSingleThreadExecutor(); - } - dialogExecutor.submit(prompter); + public void run() + { + try + { + SwingUtilities.invokeAndWait(prompter); + } catch (Exception q) + { + Cache.log.warn("Unexpected Exception in dialog thread.", q); + } + } + }); } } diff --git a/src/jalview/gui/PromptUserConfig.java b/src/jalview/gui/PromptUserConfig.java index 95d9c69..f05459b 100644 --- a/src/jalview/gui/PromptUserConfig.java +++ b/src/jalview/gui/PromptUserConfig.java @@ -200,8 +200,8 @@ public class PromptUserConfig implements Runnable } try { - int reply = JOptionPane.showInternalConfirmDialog( - Desktop.desktop, // component, + int reply = JOptionPane.showConfirmDialog( + null, // component, dialogText, dialogTitle, (allowCancel) ? JOptionPane.YES_NO_CANCEL_OPTION : JOptionPane.YES_NO_OPTION,