make sure node renderers exist when trying to disconnect

This commit is contained in:
Lera Elvoé 2024-06-14 16:59:30 +03:00
parent 0a564722f2
commit f760cd227d
No known key found for this signature in database

View file

@ -124,12 +124,18 @@ func attempt_disconnect(from_node_name: StringName, from_port: int, to_node_name
dirty = true
## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode].
## Or [code]null[/code] if none is found.
## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode],
## or [code]null[/code] if none is found.
func get_node_renderer(node: DeckNode) -> DeckNodeRendererGraphNode:
return get_node_or_null(NodePath(node._id))
## Returns the associated [DeckNodeRendererGraphNode] for the supplied [DeckNode] [member DeckNode._id],
## or [code]null[/code] if none is found.
func get_node_id_renderer(id: String) -> DeckNodeRendererGraphNode:
return get_node_or_null(NodePath(id))
func focus_node(node: DeckNodeRendererGraphNode) -> void:
set_selected(node)
var t := create_tween()
@ -349,14 +355,12 @@ func _on_add_node_menu_node_selected(type: String) -> void:
func _on_deck_nodes_disconnected(from_node_id: String, to_node_id: String, from_output_port: int, to_input_port: int) -> void:
var from_node: DeckNodeRendererGraphNode = get_children().filter(
func(x: DeckNodeRendererGraphNode):
return x.node._id == from_node_id
)[0]
var to_node: DeckNodeRendererGraphNode = get_children().filter(
func(x: DeckNodeRendererGraphNode):
return x.node._id == to_node_id
)[0]
var from_node := get_node_id_renderer(from_node_id)
if from_node == null:
return
var to_node := get_node_id_renderer(to_node_id)
if to_node == null:
return
disconnect_node(from_node.name, from_output_port, to_node.name, to_input_port)