You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nodeId parameter is always 0 when read from virtual bool deleteNode(NodeId const nodeId) override #490
It feels a bit like a positive side effect. Is it normal ? The documentation states:
inline virtual QJsonObject saveNode(NodeId const) const
Reimplement the function if you want to store/restore the node’s inner state during undo/redo node deletion operations.
But doesn't warn clearly about this requirement regarding node id validity at deletion time as it mostly states about undo/redo.
Well. My problem is solved but the reason is still unclear. The SimpleGraph example helped me well getting over this.
If you want to reproduce my "bug" scenario, just comment-out the saveNode method from the abovementioned example and observe the ID passed to deleteNode will always be 0.
If this behavior is purposeful, I would advise to set virtual QJsonObject saveNode(NodeId const) const to pure in the AbstractGraphModel class (or to make it do the bare minimum (such as the implementation above)) as this sounds like a obscure requirement for well-behaving NodeID.
Else, there might be a bug to fix in order to ensure proper ID at deletion time.
Sorry that this stayed unanswered for so long. You found a real bug, and your analysis was right. This is not a side effect you should depend on.
What happened. The delete command did not take the node id from the graph. It read the "id" key from the JSON that saveNode() returns. The default saveNode() returns an empty object, so the key was missing, and a missing key became id 0. The same failure made undo of a delete and paste of a copied node lose or crash on such models. Your override wrote "id", so it fixed the symptom.
What changes.#556 makes the library write the node id itself, so deleteNode() gets the real id with the default saveNode(). It also adds tests for delete, undo and paste through the undo stack. They fail on the old code. #557 fixes the same kind of id loss for ids of 2^31 or more on scene load.
What stays the same.saveNode() and loadNode() are still how undo restores a deleted node. With the defaults, undo of a delete cannot bring the node back, because the library has no other way to create it with its old id. The docs now say this in AbstractGraphModel, in the undo guide and in the FAQ. Making the model interface handle this directly is tracked in #554 for v4.
Activity
OpenJowel commentedon Aug 29, 2025
For some reasons, the problem was solved by overriding the non-pure "saveNode" method as follow:
It feels a bit like a positive side effect. Is it normal ? The documentation states:
But doesn't warn clearly about this requirement regarding node id validity at deletion time as it mostly states about undo/redo.
Well. My problem is solved but the reason is still unclear. The
SimpleGraphexample helped me well getting over this.If you want to reproduce my "bug" scenario, just comment-out the
saveNodemethod from the abovementioned example and observe the ID passed todeleteNodewill always be 0.If this behavior is purposeful, I would advise to set
virtual QJsonObject saveNode(NodeId const) constto pure in theAbstractGraphModelclass (or to make it do the bare minimum (such as the implementation above)) as this sounds like a obscure requirement for well-behaving NodeID.Else, there might be a bug to fix in order to ensure proper ID at deletion time.
Thank you for your attention
paceholder commentedon Nov 23, 2026
Sorry that this stayed unanswered for so long. You found a real bug, and your analysis was right. This is not a side effect you should depend on.
What happened. The delete command did not take the node id from the graph. It read the
"id"key from the JSON thatsaveNode()returns. The defaultsaveNode()returns an empty object, so the key was missing, and a missing key became id 0. The same failure made undo of a delete and paste of a copied node lose or crash on such models. Your override wrote"id", so it fixed the symptom.What changes. #556 makes the library write the node id itself, so
deleteNode()gets the real id with the defaultsaveNode(). It also adds tests for delete, undo and paste through the undo stack. They fail on the old code. #557 fixes the same kind of id loss for ids of 2^31 or more on scene load.What stays the same.
saveNode()andloadNode()are still how undo restores a deleted node. With the defaults, undo of a delete cannot bring the node back, because the library has no other way to create it with its old id. The docs now say this inAbstractGraphModel, in the undo guide and in the FAQ. Making the model interface handle this directly is tracked in #554 for v4.I will close this issue when #556 is merged.
Take the node id from the library, not from saveNode