From: <ha...@us...> - 2006-09-25 03:08:34
|
Revision: 5707 http://svn.sourceforge.net/jmol/?rev=5707&view=rev Author: hansonr Date: 2006-09-24 20:08:26 -0700 (Sun, 24 Sep 2006) Log Message: ----------- fix for exit; not working in scripts Modified Paths: -------------- trunk/Jmol/src/org/jmol/viewer/Eval.java trunk/Jmol/src/org/jmol/viewer/ScriptManager.java trunk/Jmol/src/org/jmol/viewer/Viewer.java Modified: trunk/Jmol/src/org/jmol/viewer/Eval.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-09-24 23:45:41 UTC (rev 5706) +++ trunk/Jmol/src/org/jmol/viewer/Eval.java 2006-09-25 03:08:26 UTC (rev 5707) @@ -77,14 +77,14 @@ } void haltExecution() { - interruptExecution = true; + interruptExecution = Boolean.TRUE; } boolean isScriptExecuting() { - return isExecuting && !interruptExecution; + return isExecuting && !interruptExecution.booleanValue(); } - boolean interruptExecution = false; + static Boolean interruptExecution = Boolean.FALSE; boolean isExecuting = false; Thread currentThread = null; @@ -92,7 +92,7 @@ public void runEval() { // only one reference now -- in Viewer refresh(); viewer.pushHoldRepaint(); - interruptExecution = false; + interruptExecution = Boolean.FALSE; isExecuting = true; currentThread = Thread.currentThread(); @@ -107,14 +107,12 @@ timeEndExecution = System.currentTimeMillis(); - if (errorMessage == null && interruptExecution) + if (errorMessage == null && interruptExecution.booleanValue()) errorMessage = "execution interrupted"; // if (errorMessage != null) // viewer.scriptStatus("script ERROR: " + errorMessage); else if (!tQuiet) - viewer.scriptStatus("Script completed"); - - interruptExecution = false; + viewer.scriptStatus("Script completed"); isExecuting = false; viewer.setTainted(true); viewer.popHoldRepaint(); @@ -360,7 +358,7 @@ viewer.scriptStatus("Eval.instructionDispatchLoop():" + timeBegin); viewer.scriptStatus(toString()); } - while (!interruptExecution && pc < aatoken.length) { + while (!interruptExecution.booleanValue() && pc < aatoken.length) { statement = aatoken[pc++]; statementLength = statement.length; if (logMessages) @@ -393,9 +391,10 @@ message(); break; case Token.exit: // flush the queue and... - viewer.clearScriptQueue(); + if (pc > 1) + viewer.clearScriptQueue(); case Token.quit: // quit this only if it isn't the first command - interruptExecution = (pc > 1 || ! viewer.scriptManager.useQueue); + interruptExecution = ((pc > 1 || ! viewer.scriptManager.useQueue) ? Boolean.TRUE : Boolean.FALSE); break; case Token.label: label(); @@ -2650,7 +2649,7 @@ millis -= seconds * 1000; if (millis <= 0) millis = 1; - while (seconds >= 0 && millis > 0 && !interruptExecution && currentThread == Thread.currentThread()) { + while (seconds >= 0 && millis > 0 && !interruptExecution.booleanValue() && currentThread == Thread.currentThread()) { viewer.popHoldRepaint(); try { Thread.sleep((seconds--) > 0 ? 1000 : millis); Modified: trunk/Jmol/src/org/jmol/viewer/ScriptManager.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/ScriptManager.java 2006-09-24 23:45:41 UTC (rev 5706) +++ trunk/Jmol/src/org/jmol/viewer/ScriptManager.java 2006-09-25 03:08:26 UTC (rev 5707) @@ -115,11 +115,11 @@ boolean isQuiet = ((Boolean) scriptItem.get(4)).booleanValue(); Vector tokenInfo = (Vector) scriptItem.get(5); Logger.debug(scriptQueue.size() + " scripts; running: " + script); + scriptQueue.remove(0); Object returnInfo = runScript(returnType, script, statusList, isScriptFile, isQuiet, tokenInfo); if (scriptQueue.size() == 0) // might have been cleared with an exit return null; - scriptQueue.remove(0); return returnInfo; } @@ -132,19 +132,27 @@ } private void startScriptQueue() { - if (queueThread != null) + if (scriptQueueRunning) return; queueThread = new Thread(new ScriptQueueRunnable()); queueThread.start(); } + boolean scriptQueueRunning; class ScriptQueueRunnable implements Runnable { public void run() { - Logger.debug("script thread running"); + scriptQueueRunning = true; while (scriptQueue.size() != 0) { runNextScript(); } + scriptQueueRunning = false; queueThread = null; - } + } + + public void stop() { + scriptQueueRunning = false; + } } + + } Modified: trunk/Jmol/src/org/jmol/viewer/Viewer.java =================================================================== --- trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-09-24 23:45:41 UTC (rev 5706) +++ trunk/Jmol/src/org/jmol/viewer/Viewer.java 2006-09-25 03:08:26 UTC (rev 5707) @@ -2027,7 +2027,7 @@ public String script(String strScript) { return evalString(strScript); } - + public String evalString(String strScript) { if (checkHalt(strScript)) return "script execution halted"; @@ -2094,6 +2094,7 @@ return "script execution halted"; if (strScript == null) return null; + //typically request: "+scriptStarted,+scriptStatus,+scriptEcho,+scriptTerminated" //set up first with applet.jmolGetProperty("jmolStatus",statusList) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |