1
0
Fork 0

setlistener: tolerate being call()-ed

Fix bug https://sourceforge.net/p/flightgear/codetickets/2219/
Changes to logging mean than setlistener breaks when invoked via
call(), which occurs in the Warthog Nasal scripting. The problem is
that call() forces caller() to return nil, which the setlistener()
debug code did not check for.
This commit is contained in:
James Turner 2020-04-27 22:50:34 +01:00
parent 7d78937a4c
commit f074504326

View file

@ -118,8 +118,11 @@ var setlistener = func(node, fn, init = 0, runtime = 1) {
var id = _setlistener(node, func(chg, lst, mode, is_child) {
fn(props.wrapNode(chg), props.wrapNode(lst), mode, is_child);
}, init, runtime);
var c = caller();
logprint(LOG_DEBUG, "setting listener #",id," in ",c[2],":",c[3]);
if (c != nil) {
logprint(LOG_DEBUG, "setting listener #",id," in ",c[2],":",c[3]);
}
return id;
}