...
 
Commits (2)
  • Rob Swindell's avatar
    Always evaluate js.on_exit() installed expressions. · 175d0fbc
    Rob Swindell authored
    I noticed that when executing an external JS with the new "Use Shell / New Context" option set to "Yes", that any expressions (strings) installed via js.on_exit() were not being executed upon exit from the script. These on-exit strings are important for restoring global state information (e.g. control key pass-through, console mode) to the original state before the JS mod made any changes.
    
    I'm not sure why the special treatment of "scope == NULL" is through-out this function. Going back to v3.16, it appears this was special treatment for JS mods invoked via global hot key event (when scope != NULL). When invoking an xtrn JS mod with the new Context option, the scope argument is not NULL, so this check was defeating the parsing of the "exit_code" and the evaluation of any js.on_exit() installed expressions for no apparent reason. I can't think why global hot key events should be excluded from this logic either.
    175d0fbc
  • Rob Swindell's avatar
    a85180be
......@@ -696,13 +696,11 @@ long sbbs_t::js_execfile(const char *cmd, const char* startup_dir, JSObject* sco
JS_ExecuteScript(js_cx, js_scope, js_script, &rval);
sys_status &=~ SS_ABORT;
if(scope==NULL) {
JS_GetProperty(js_cx, js_scope, "exit_code", &rval);
if(rval!=JSVAL_VOID)
JS_ValueToInt32(js_cx,rval,&result);
JS_GetProperty(js_cx, js_scope, "exit_code", &rval);
if(rval!=JSVAL_VOID)
JS_ValueToInt32(js_cx,rval,&result);
js_EvalOnExit(js_cx, js_scope, &js_callback);
}
js_EvalOnExit(js_cx, js_scope, &js_callback);
JS_ReportPendingException(js_cx); /* Added Dec-4-2005, rswindell */
......