Fix a node with an invalid number of outputs

This commit is contained in:
GogoVega 2024-06-26 19:42:26 +02:00
parent 1b5b3f7f88
commit a743764345
No known key found for this signature in database
GPG Key ID: E1E048B63AC5AC2B

View File

@ -2321,29 +2321,29 @@ RED.nodes = (function() {
node.type = "unknown";
}
if (node._def.category != "config") {
if (n.hasOwnProperty('inputs')) {
node.inputs = n.inputs;
if (n.hasOwnProperty('inputs') && def.defaults.hasOwnProperty("inputs")) {
node.inputs = parseInt(n.inputs, 10);
node._config.inputs = JSON.stringify(n.inputs);
} else {
node.inputs = node._def.inputs;
}
if (n.hasOwnProperty('outputs')) {
node.outputs = n.outputs;
if (n.hasOwnProperty('outputs') && def.defaults.hasOwnProperty("outputs")) {
node.outputs = parseInt(n.outputs, 10);
node._config.outputs = JSON.stringify(n.outputs);
} else {
node.outputs = node._def.outputs;
}
if (node.hasOwnProperty('wires') && node.wires.length > node.outputs) {
if (!node._def.defaults.hasOwnProperty("outputs") || !isNaN(parseInt(n.outputs))) {
// If 'wires' is longer than outputs, clip wires
console.log("Warning: node.wires longer than node.outputs - trimming wires:",node.id," wires:",node.wires.length," outputs:",node.outputs);
node.wires = node.wires.slice(0,node.outputs);
} else {
// The node declares outputs in its defaults, but has not got a valid value
// Defer to the length of the wires array
node.outputs = node.wires.length;
}
// The node declares outputs in its defaults, but has not got a valid value
// Defer to the length of the wires array
if (isNaN(node.outputs)) {
node.outputs = node.wires.length;
} else if (node.wires.length > node.outputs) {
// If 'wires' is longer than outputs, clip wires
console.log("Warning: node.wires longer than node.outputs - trimming wires:", node.id, " wires:", node.wires.length, " outputs:", node.outputs);
node.wires = node.wires.slice(0, node.outputs);
}
for (d in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(d) && d !== 'inputs' && d !== 'outputs') {
node[d] = n[d];