From f6b699b87c2666f105973aa0be80e2dc62ed39e6 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 1 Oct 2012 12:15:10 +0100 Subject: [PATCH] JAL-1183 dialog thread is only started after the splashscreen goes away --- src/jalview/gui/Desktop.java | 22 ++++++++++++++++++++++ src/jalview/gui/SplashScreen.java | 1 + 2 files changed, 23 insertions(+) diff --git a/src/jalview/gui/Desktop.java b/src/jalview/gui/Desktop.java index 50f0095..d357e4f 100644 --- a/src/jalview/gui/Desktop.java +++ b/src/jalview/gui/Desktop.java @@ -67,6 +67,7 @@ import java.util.StringTokenizer; import java.util.Vector; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.Semaphore; import javax.swing.DefaultDesktopManager; import javax.swing.DesktopManager; @@ -2618,6 +2619,14 @@ public class Desktop extends jalview.jbgui.GDesktop implements * single thread that handles display of dialogs to user. */ ExecutorService dialogExecutor=Executors.newSingleThreadExecutor(); + /** + * flag indicating if dialogExecutor should try to acquire a permit + */ + private volatile boolean dialogPause=true; + /** + * pause the queue + */ + private java.util.concurrent.Semaphore block=new Semaphore(0); /** * add another dialog thread to the queue @@ -2629,6 +2638,13 @@ public class Desktop extends jalview.jbgui.GDesktop implements { public void run() { + if (dialogPause) { + try { block.acquire(); } catch (InterruptedException x){}; + } + if (instance==null) + { + return; + } try { SwingUtilities.invokeAndWait(prompter); @@ -2640,4 +2656,10 @@ public class Desktop extends jalview.jbgui.GDesktop implements }); } + public void startDialogQueue() + { + // set the flag so we don't pause waiting for another permit and semaphore the current task to begin + dialogPause=false; + block.release(); + } } diff --git a/src/jalview/gui/SplashScreen.java b/src/jalview/gui/SplashScreen.java index 15914df..6fcb6a0 100755 --- a/src/jalview/gui/SplashScreen.java +++ b/src/jalview/gui/SplashScreen.java @@ -197,6 +197,7 @@ public class SplashScreen extends JPanel implements Runnable, HyperlinkListener } closeSplash(); + Desktop.instance.startDialogQueue(); } /** -- 1.7.10.2