Adding undo/redo support for replace node.
Created by: Nibodhika
This is a proposed solution for #19326 (closed), I'm not sure about some of these changes:
- I had to remove
memdelete(n);
otherwise undo would fail because the node was already freed, can I trust thatadd_undo_reference
will free the pointer when the history gets deleted? - I have absolutely no idea why
editor_data->get_undo_redo().clear_history();
was being called there. - I'm not sure the nodes that were being collected for deletion in
to_erase
should be stored as an undo reference (since they weren't really children of n for what I understood), on the other hand I think that freeing those nodes via hardcode as it was here might cause problems when undoing multiple times (this was not a problem until now because of the clear_history, which might explain why that was there in the first place) - I had to remove
editor->push_item(newnode);
because it was spiting an error about the newnode being inside the tree, which I have no idea why it started to happen with these changes, but afaik it shouldn't.