imgui-node-editor icon indicating copy to clipboard operation
imgui-node-editor copied to clipboard

Removing node does not delete connected links

Open sodamouse opened this issue 1 year ago • 0 comments

Hi, I saw in another closed issue that this problem was fixed in develop, however this does not seem to be the case. When I delete a node, QueryDeletedLink does not return anything, and the second while loop is never executed.

Repro:

if (ax::NodeEditor::BeginDelete())
{
	ax::NodeEditor::NodeId deletedNodeId;
	while (ax::NodeEditor::QueryDeletedNode(&deletedNodeId))
	{
		if (ax::NodeEditor::AcceptDeletedItem)
		{
			auto it = std::find_if(nodes.begin(), nodes.end(), [deletedNodeId](Node& node) {
				return node.id == deletedNodeId.Get();
			});
			
			if (it != nodes.end())
			{
				std::cout << "removed node: " << it->id << '\n';
				nodes.erase(it);
			}
		}
	}

	ax::NodeEditor::LinkId deletedLinkId;
	while (ax::NodeEditor::QueryDeletedLink(&deletedLinkId))
	{
		if (ax::NodeEditor::AcceptDeletedItem())
		{
			auto it = std::find_if(links.begin(), links.end(), [deletedLinkId](Link& link) {
				return link.id == deletedLinkId.Get();
			});

			if (it != links.end())
			{
				std::cout << "removed link: " << it->id << '\n';
				links.erase(it);
			}
		}
	}

        ax::NodeEditor::EndDelete();
}

sodamouse avatar Jan 17 '24 05:01 sodamouse