From cb03edaa1450e5716bd37ca5cc430a46c245e9db Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 1 Oct 2012 10:56:21 +0100 Subject: [PATCH] JAL-1184 apparent deadlock when launching jalview on w7 - attempt to patch --- src/jalview/gui/Desktop.java | 21 +++++++++++++++------ src/jalview/gui/PromptUserConfig.java | 4 ++-- 2 files changed, 17 insertions(+), 8 deletions(-) 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, -- 1.7.10.2