From 3442a3a086f518c31c308e8012258d4300f3276a Mon Sep 17 00:00:00 2001 From: Ilya Bogdanov Date: Mon, 2 Sep 2024 23:43:15 +0400 Subject: [PATCH] Ignore port updates on removed nodes (#10950) Fixes #10888, #10925 --- app/gui2/src/stores/graph/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/gui2/src/stores/graph/index.ts b/app/gui2/src/stores/graph/index.ts index f951b3b3a72a..97d8af9f42ce 100644 --- a/app/gui2/src/stores/graph/index.ts +++ b/app/gui2/src/stores/graph/index.ts @@ -312,16 +312,24 @@ export const { injectFn: useGraphStore, provideFn: provideGraphStore } = createC function deleteNodes(ids: Iterable) { edit((edit) => { + const deletedNodes = new Set() for (const id of ids) { const node = db.nodeIdToNode.get(id) if (!node) continue if (node.type !== 'component') continue const usages = db.getNodeUsages(id) - for (const usage of usages) updatePortValue(edit, usage, undefined) + for (const usage of usages) { + const nodeId = getPortPrimaryInstance(usage)?.nodeId + // Skip ports on already deleted nodes. + if (nodeId && deletedNodes.has(nodeId)) continue + + updatePortValue(edit, usage, undefined) + } const outerExpr = edit.getVersion(node.outerExpr) if (outerExpr) Ast.deleteFromParentBlock(outerExpr) nodeRects.delete(id) nodeHoverAnimations.delete(id) + deletedNodes.add(id) } }) }