Node deletion with multiple links connected to same output throws an "Item not found" error.
Version of Dear PyGui
Version: 2.0.0 Operating System: macOS 15.1.1
My Issue/Question
Deleting a node with multiple links connected to a single of its outputs leads to "Item not found" error on some link ids.
Error message:
Exception:
Error: [1005]
Command: delete_item
Item: 0
Label: Not found
Item Type: Unknown
Message: Item not found: 40
To Reproduce
Create two nodes with multiple inputs / outputs. Connect single output of first node to multiple inputs of second node. Delete first node. => Item not found error.
Expected behavior
Should delete all links cleanly.
Standalone, minimal, complete and verifiable example
import dearpygui.dearpygui as dpg
dpg.create_context()
def link_callback(sender, links):
dpg.add_node_link(links[0], links[1], parent=sender)
def delink_callback(sender, link):
dpg.delete_item(link)
def delNodes(sender):
lst = dpg.get_selected_nodes("node_edit")
for node in lst:
dpg.delete_item(node)
with dpg.window(tag="window", label="Del node bug", width=400, height=400):
dpg.add_menu_item(label="Delete", callback=delNodes)
with dpg.node_editor(parent="window", tag="node_edit", callback=link_callback, delink_callback=delink_callback):
with dpg.node(tag=2000, label="Node 1"):
with dpg.node_attribute(tag=100, label="s1", attribute_type=dpg.mvNode_Attr_Input):
dpg.add_text("intextonly")
with dpg.node_attribute(tag=200, label="s2", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_text("outtextonly")
with dpg.node_attribute(label="s2", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_text("outtextonly")
with dpg.node_attribute(tag=300, label="s3", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_text("outextonly")
with dpg.node(tag=3000, label="Node 2"):
with dpg.node_attribute(tag=400, label="s1", attribute_type=dpg.mvNode_Attr_Input):
dpg.add_text("intextonly")
with dpg.node_attribute(tag=500, label="s2", attribute_type=dpg.mvNode_Attr_Input):
dpg.add_text("intextonly")
with dpg.node_attribute(label="s2", attribute_type=dpg.mvNode_Attr_Input):
dpg.add_text("intextonly")
with dpg.node_attribute(label="s2", attribute_type=dpg.mvNode_Attr_Input):
dpg.add_text("intextonly")
with dpg.node_attribute(tag=600, label="s3", attribute_type=dpg.mvNode_Attr_Output):
dpg.add_text("outtextonly")
dpg.create_viewport(title='Del node bug', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.set_primary_window("window", True)
dpg.start_dearpygui()
dpg.destroy_context()
Good catch! Looks like a bug in mvNodeEditor::onChildRemoved: the function is trying to remove node links while it is iterating over the list of those node links :joy: (childslots[0]). It also makes an unnecessary call to CleanUpItem, so whoever goes ahead and fixes this, please remove the call.
A workaround would be to manually remove all the links tied to the node being deleted.