From 3d9f4229c16572139eac0f1e1a2decad9cd6f764 Mon Sep 17 00:00:00 2001 From: ssit Date: Sun, 25 Jun 2023 14:03:32 -0400 Subject: [PATCH] Fix reroutes updating to wildcards on graph load The type of reroutes connected to primitive nodes may be lost when the graph is loaded, depending on the configuration order of nodes. Also fixed an error when a primitive widget callback is called and is connected to a reroute without output links. --- web/extensions/core/rerouteNode.js | 7 +++++++ web/extensions/core/widgetInputs.js | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/web/extensions/core/rerouteNode.js b/web/extensions/core/rerouteNode.js index 83aea6361..0b65a51e8 100644 --- a/web/extensions/core/rerouteNode.js +++ b/web/extensions/core/rerouteNode.js @@ -55,6 +55,7 @@ app.registerExtension({ let updateNodes = []; let inputType = null; let inputNode = null; + let rootNode = null; while (currentNode) { updateNodes.unshift(currentNode); const linkId = currentNode.inputs[0].link; @@ -76,6 +77,7 @@ app.registerExtension({ // We've found the end inputNode = currentNode; inputType = node.outputs[link.origin_slot]?.type ?? null; + rootNode = node; break; } } else { @@ -123,6 +125,11 @@ app.registerExtension({ } } + if (rootNode?.constructor.type === "PrimitiveNode" && inputType === "*") { + // Primitive doesn't have type yet, skip update + return; + } + const displayType = (inputType === "*" && outputType) || inputType || outputType || "*"; const color = LGraphCanvas.link_type_colors[displayType]; diff --git a/web/extensions/core/widgetInputs.js b/web/extensions/core/widgetInputs.js index 6b5174968..8fd110bc4 100644 --- a/web/extensions/core/widgetInputs.js +++ b/web/extensions/core/widgetInputs.js @@ -210,7 +210,7 @@ app.registerExtension({ function get_links(node) { let links = []; - for (const l of node.outputs[0].links) { + for (const l of node.outputs[0].links ?? []) { const linkInfo = app.graph.links[l]; const n = node.graph.getNodeById(linkInfo.target_id); if (n.type == "Reroute") {