Issue with removing GraphNodes from a GraphEdit.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Void

Right now, I’m working on a dialog editor using GraphEdit/GraphNode, but I’ve hit an issue with deleting nodes that have connections.

I have a graph setup like so:

Graph setup

When the close button is pressed, the following code runs on the graph:

var node_to_delete = graph.get_node(name)

It has to be run on the graph and not the actual node so that UndoRedo works with the setup. However, when the node is deleted, the connections are left behind:

The issue

The same issue occurs if I only remove the node as a child of the graph, or just queue_free it.

The next time the graph refreshes (via scrolling, zooming in, or adding another node), these connections all disappear, and the debugger says that it can’t find the deleted node.

How am I supposed to properly remove a GraphNode from a scene? The visual shader editor doesn’t have this issue, so there has to be a proper way of doing it that doesn’t have this error.

I’m using Godot 3.1.1 stable, on Linux Mint 19.2.

:bust_in_silhouette: Reply From: huahuapro

i have the same issue, need help!

In the end, I ended up manually disconnecting everything via parsing GraphEdit.get_connection_list(). I can share the code if you want.

Void | 2020-03-11 16:29

please, i want the code, thanks!

huahuapro | 2020-03-12 00:25

thanks so much! i learn a lot by reading your code.

huahuapro | 2020-03-13 01:00