1
0
Fork 0

crashfix: handleCommand() is called from other modules (input callbacks,

fgcommands from C++ or GUI), so we need a separate context here. (See
also solution in FGNasalListener::valueChanged)
This commit is contained in:
mfranz 2006-03-08 16:06:32 +00:00
parent b7ef6d8cef
commit 6867462210

View file

@ -533,12 +533,13 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
naRef code = parse(arg->getPath(true), nasal, strlen(nasal));
if(naIsNil(code)) return false;
naContext c = naNewContext();
naRef locals = naNil();
if (moduleName[0]) {
naRef modname = naNewString(_context);
if(moduleName[0]) {
naRef modname = naNewString(c);
naStr_fromdata(modname, (char*)moduleName, strlen(moduleName));
if(!naHash_get(_globals, modname, &locals))
locals = naNewHash(_context);
locals = naNewHash(c);
}
// Cache the command argument for inspection via cmdarg(). For
// performance reasons, we won't bother with it if the invoked
@ -546,10 +547,15 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
_cmdArg = (SGPropertyNode*)arg;
// Call it!
naRef result = naCall(_context, code, 0, 0, naNil(), locals);
if(!naGetError(_context)) return true;
logError(_context);
return false;
naModUnlock();
naRef result = naCall(c, code, 0, 0, naNil(), locals);
naModLock();
bool error = naGetError(c);
if(error)
logError(c);
naFreeContext(c);
return !error;
}
// settimer(func, dt, simtime) extension function. The first argument