imnodes
imnodes copied to clipboard
Crash during node or link delete operation
Crash happens if push consecutive 'x' key
Reproduction steps with links.
- create multiple nodes.
- connect the links between the nodes
- select a link
- push 'x' button to delete the link
- push 'x' button once again.. => crash
Reproduction steps with nodes.
- create multiple nodes.
- select a node
- push 'x' button to delete the node
- push 'x' button once again.. => crash
Visual confusion.
- create multiple nodes or links => the nodes or links already emphasized with bold color, but the node or link is not selected.
- push 'x' button => nothing happens because the selection index doesn't have any item.
It would be best if you show some code: how do you delete the nodes/links?
I think @EssenWorkbench is referencing the example code.
This is not a library bug and likely a flaw in the example code.
I also encountered this problem, from what I investigated the problem is that ImNodes::NumSelectedNodes returns 1 when no node is selected and then after querying the node id it returns INT_MIN.
For me the code here is:
if (aderite::Engine::getInputManager()->isKeyPressed(input::Key::DEL)) {
std::vector<int> nodes;
LOG_TRACE("Num selected: {0}", ImNodes::NumSelectedNodes());
nodes.resize(ImNodes::NumSelectedNodes());
ImNodes::GetSelectedNodes(nodes.data());
for (int node : nodes) {
LOG_TRACE("Node: {0}", node);
m_currentState->deleteNode(node);
}
}
And the log:
[11:28:36.527] thread 18860 | Num selected: 1 [11:28:36.528] thread 18860 | Node: 26 [11:28:36.544] thread 18860 | Num selected: 1 [11:28:36.545] thread 18860 | Node: -2147483648 [11:28:36.546] thread 18860 | Failed to delete node -2147483648 [11:28:36.560] thread 18860 | Num selected: 1 [11:28:36.560] thread 18860 | Node: -2147483648 [11:28:36.561] thread 18860 | Failed to delete node -2147483648 [11:28:36.577] thread 18860 | Num selected: 1 [11:28:36.578] thread 18860 | Node: -2147483648 [11:28:36.578] thread 18860 | Failed to delete node -2147483648 [11:28:36.593] thread 18860 | Num selected: 1 [11:28:36.594] thread 18860 | Node: -2147483648 [11:28:36.595] thread 18860 | Failed to delete node -2147483648
This only happens when deleting a node. If I don't select anything and try to delete then num selected will return 0 as expected.
... or it is? which version(commit) are you running? I am running a multiple months old commit with out issues (c63f347f06f16f78249bdd0914b1bc04dabc4f0a) .
I am using e563371cee49eb42da08cca1e0209d30d452c665
Please refer to here https://github.com/Nelarius/imnodes/blob/e563371cee49eb42da08cca1e0209d30d452c665/imnodes.h#L350-L364 Clearing the selected nodes or links before deletion is delegated to the user.
Yeah, that fixed it