Skip to content

Adding undo/redo support for replace node.

Rafał Mikrut requested to merge github/fork/Nibodhika/19326 into master

Created by: Nibodhika

This is a proposed solution for #19326 (closed), I'm not sure about some of these changes:

  1. I had to remove memdelete(n); otherwise undo would fail because the node was already freed, can I trust that add_undo_reference will free the pointer when the history gets deleted?
  2. I have absolutely no idea why editor_data->get_undo_redo().clear_history(); was being called there.
  3. 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)
  4. 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.

Merge request reports

Loading