JAL-1184 apparent deadlock when launching jalview on w7 - attempt to patch
authorjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 1 Oct 2012 09:56:21 +0000 (10:56 +0100)
committerjprocter <jprocter@compbio.dundee.ac.uk>
Mon, 1 Oct 2012 10:13:47 +0000 (11:13 +0100)
src/jalview/gui/Desktop.java
src/jalview/gui/PromptUserConfig.java

index d1e8b6a..50f0095 100644 (file)
@@ -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);
+        }
+      }
+    });
   }
 
 }
index 95d9c69..f05459b 100644 (file)
@@ -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,