1
0
Fork 0

Fix path validation (ensure listeners are attached to existing nodes)

This commit is contained in:
Thomas Geymayer 2013-04-29 22:19:33 +02:00
parent 63138932cb
commit d80722065f
2 changed files with 8 additions and 1 deletions

View file

@ -331,7 +331,7 @@ _setlistener("/sim/signals/nasal-dir-initialized", func {
var write_validator = func(n) setValue(n, [valid(getValue(n, []), write_rules) or ""]);
# validation listeners for load[xml]/save[xml]/parsexml() (see utils.cxx:fgValidatePath)
var n = props.globals.getNode("/sim/paths/validate", 1).remove();
var n = props.globals.getNode("/sim/paths/validate", 1).removeAllChildren();
var rval = _setlistener(n.getNode("read", 1)._g, read_validator);
var wval = _setlistener(n.getNode("write", 1)._g, write_validator);

View file

@ -32,6 +32,7 @@ var Node = {
setDoubleValue : func _setDoubleValue(me._g, arg),
unalias : func _unalias(me._g, arg),
alias : func(n) _alias(me._g, [isa(n, Node) ? n._g : n]),
equals : func(n) _equals(me._g, [isa(n, Node) ? n._g : n]),
clearValue : func _alias(me._g, [_globals()]) and me.unalias(),
getPath : func {
@ -52,6 +53,12 @@ var Node = {
if((var p = me.getParent()) == nil) return nil;
p.removeChild(me.getName(), me.getIndex());
},
removeAllChildren : func {
foreach(var c; me.getChildren())
me.removeChild(c.getName(), c.getIndex());
return me;
},
};
##