X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fjavascript%2FJSFunctionExec.java;h=3e1029492cbfeb6c83c5a43ed769253c2a07e1ea;hb=7b3215a40ae93915da4026d5877ebbe447c1fc7e;hp=6ab086583d344e552c62b5b2e59bb3b17ec700f1;hpb=5408a7058422f1d268fcb18a9516789248912d95;p=jalview.git
diff --git a/src/jalview/javascript/JSFunctionExec.java b/src/jalview/javascript/JSFunctionExec.java
index 6ab0865..3e10294 100644
--- a/src/jalview/javascript/JSFunctionExec.java
+++ b/src/jalview/javascript/JSFunctionExec.java
@@ -1,3 +1,20 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
+ * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ */
package jalview.javascript;
import java.net.URL;
@@ -9,33 +26,57 @@ import jalview.bin.JalviewLite;
public class JSFunctionExec implements Runnable
{
- JalviewLite jvlite;
+ public JalviewLite jvlite;
public JSFunctionExec(JalviewLite applet)
{
jvlite = applet;
+
+ jsExecQueue = jvlite.getJsExecQueue();
+ jvlite.setExecutor(this);
+ }
+
+ public void finalize()
+ {
+ jvlite = null;
+ executor = null;
+ if (jsExecQueue != null)
+ {
+ jsExecQueue.clear();
+ }
+ jsExecQueue = null;
}
- private static Vector jsExecQueue;
+ private Vector jsExecQueue;
- private static Thread executor = null;
+ private Thread executor = null;
- public static void stopQueue()
+ public void stopQueue()
{
if (jsExecQueue != null)
{
+ Vector q = null;
synchronized (jsExecQueue)
{
- Vector q = jsExecQueue;
- q.removeAllElements();
+ q = jsExecQueue;
jsExecQueue = null;
+ }
+ if (q != null)
+ {
+ for (JSFunctionExec jx : q)
+ {
+ jx.jvlite = null;
+
+ }
+ q.removeAllElements();
synchronized (q)
{
q.notifyAll();
}
}
- executor = null;
}
+ jvlite = null;
+ executor = null;
}
public void run()
@@ -75,7 +116,7 @@ public class JSFunctionExec implements Runnable
}
/**
- * execute a javascript callback asynchronously
+ * execute a javascript callback synchronously
*
* @param _listener
* @param objects
@@ -149,7 +190,8 @@ public class JSFunctionExec implements Runnable
{
System.err.println(jex);
}
- if (jex instanceof netscape.javascript.JSException)
+ if (jex instanceof netscape.javascript.JSException
+ && jvlite.jsfallbackEnabled)
{
jsex[0] = (netscape.javascript.JSException) jex;
if (jvlite.debug)
@@ -211,10 +253,9 @@ public class JSFunctionExec implements Runnable
};
if (async)
{
- if (JSFunctionExec.executor == null)
+ if (executor == null)
{
- JSFunctionExec.jsExecQueue = new Vector();
- JSFunctionExec.executor = new Thread(new JSFunctionExec(jvlite));
+ executor = new Thread(new JSFunctionExec(jvlite));
executor.start();
}
synchronized (jsExecQueue)
@@ -225,6 +266,7 @@ public class JSFunctionExec implements Runnable
}
else
{
+ // wat for executor to notify us if it's running.
exec.run();
if (jsex[0] != null)
{