[fix] Clean up slot references when removing widgets (#1107)

This commit is contained in:
Christian Byrne
2025-07-07 23:14:35 -07:00
committed by GitHub
parent 2b831d5d87
commit 3db44707fa

View File

@@ -1805,6 +1805,16 @@ export class LGraphNode implements NodeLike, Positionable, IPinnable, IColorable
const widgetIndex = this.widgets.indexOf(widget)
if (widgetIndex === -1) throw new Error("Widget not found on this node")
// Clean up slot references to prevent memory leaks
if (this.inputs) {
for (const input of this.inputs) {
if (input._widget === widget) {
input._widget = undefined
delete input.widget
}
}
}
this.widgets.splice(widgetIndex, 1)
}