From 8df5e33109bf4642bc0d720646e32ca2520c1d91 Mon Sep 17 00:00:00 2001 From: rgthree Date: Tue, 5 Nov 2024 23:09:30 -0500 Subject: [PATCH] Use passed value 'to' for mode change rather than accessing this.mode (as other getters may be in the way). Partly for #362 --- src_web/comfyui/node_mode_relay.ts | 3 ++- src_web/comfyui/node_mode_repeater.ts | 8 ++++++-- web/comfyui/node_mode_relay.js | 2 +- web/comfyui/node_mode_repeater.js | 6 ++++-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src_web/comfyui/node_mode_relay.ts b/src_web/comfyui/node_mode_relay.ts index 327c61d..1b9c74d 100644 --- a/src_web/comfyui/node_mode_relay.ts +++ b/src_web/comfyui/node_mode_relay.ts @@ -103,7 +103,8 @@ class NodeModeRelay extends BaseCollectorNode { if (this.inputs.length <= 1 && !this.isInputConnected(0) && this.isAnyOutputConnected()) { const [n, v] = logger.infoParts(`Mode change without any inputs; relaying our mode.`); console[n]?.(...v); - this.dispatchModeToRepeater(this.mode); + // Pass "to" since there may be other getters in the way to access this.mode directly. + this.dispatchModeToRepeater(to); } } diff --git a/src_web/comfyui/node_mode_repeater.ts b/src_web/comfyui/node_mode_repeater.ts index 1f8e468..8174439 100644 --- a/src_web/comfyui/node_mode_repeater.ts +++ b/src_web/comfyui/node_mode_repeater.ts @@ -167,7 +167,8 @@ class NodeModeRepeater extends BaseCollectorNode { if (linkedNodes.length) { for (const node of linkedNodes) { if (node.type !== NodeTypesString.NODE_MODE_RELAY) { - node.mode = this.mode; + // Use "to" as there may be other getters in the way to access this.mode directly. + node.mode = to; } } } else if (app.graph._groups?.length) { @@ -176,7 +177,10 @@ class NodeModeRepeater extends BaseCollectorNode { group.recomputeInsideNodes(); if (group._nodes?.includes(this)) { for (const node of group._nodes) { - node.mode = this.mode; + if (node !== this) { + // Use "to" as there may be other getters in the way to access this.mode directly. + node.mode = to; + } } } } diff --git a/web/comfyui/node_mode_relay.js b/web/comfyui/node_mode_relay.js index 8343e6c..886485d 100644 --- a/web/comfyui/node_mode_relay.js +++ b/web/comfyui/node_mode_relay.js @@ -55,7 +55,7 @@ class NodeModeRelay extends BaseCollectorNode { if (this.inputs.length <= 1 && !this.isInputConnected(0) && this.isAnyOutputConnected()) { const [n, v] = logger.infoParts(`Mode change without any inputs; relaying our mode.`); (_a = console[n]) === null || _a === void 0 ? void 0 : _a.call(console, ...v); - this.dispatchModeToRepeater(this.mode); + this.dispatchModeToRepeater(to); } } configure(info) { diff --git a/web/comfyui/node_mode_repeater.js b/web/comfyui/node_mode_repeater.js index 674de8f..22953d1 100644 --- a/web/comfyui/node_mode_repeater.js +++ b/web/comfyui/node_mode_repeater.js @@ -100,7 +100,7 @@ class NodeModeRepeater extends BaseCollectorNode { if (linkedNodes.length) { for (const node of linkedNodes) { if (node.type !== NodeTypesString.NODE_MODE_RELAY) { - node.mode = this.mode; + node.mode = to; } } } @@ -109,7 +109,9 @@ class NodeModeRepeater extends BaseCollectorNode { group.recomputeInsideNodes(); if ((_b = group._nodes) === null || _b === void 0 ? void 0 : _b.includes(this)) { for (const node of group._nodes) { - node.mode = this.mode; + if (node !== this) { + node.mode = to; + } } } }