Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding undo/redo support for replace node. #22921

Closed
wants to merge 1 commit into from

Conversation

Nibodhika
Copy link
Contributor

@Nibodhika Nibodhika commented Oct 11, 2018

This is a proposed solution for #19326, 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.

@@ -1705,7 +1708,10 @@ void SceneTreeDock::_create() {
ERR_FAIL_COND(!newnode);

replace_node(n, newnode);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clang-format says this empty line before the } should be removed. https://travis-ci.org/godotengine/godot/jobs/439926660#L534

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw that yesterday before going to bed, fixed it, amended the commit and pushed, saw tarvis start up again so I turned my computer off and went to bed. So when I read this comment this morning I thought "yeah, I already fixed it", but I saw tarvis was still broken, and the line was still there... Apparently I forgot to add the changes to the file before amending the commit, kids, don't git while tired.

@akien-mga akien-mga added this to the 3.1 milestone Oct 16, 2018
@Xrayez
Copy link
Contributor

Xrayez commented Oct 23, 2018

Your conclusions about the change reflects mine as I tried to fix the issue!

Also, related to #21363.

@akien-mga
Copy link
Member

Moving to 3.2 milestone as we're about to enter the beta stage and release freeze for Godot 3.1. Only bug fixes against issues of the 3.1 milestone (or enhancements to core features of the 3.1 roadmap) will be considered until 3.1-stable is released.

Note: If it's merged after 3.1-stable is released, this change might be considered for cherry-picking into a later 3.1.x release.

@akien-mga akien-mga modified the milestones: 3.1, 3.2 Dec 12, 2018
@KoBeWi
Copy link
Member

KoBeWi commented Jun 28, 2019

In #28349 I made some changes to SceneTreeDock's replace_node, which resulted in merge conflicts with this PR. The change was to actually add support for replacing node without freeing it, which should make the original purpose of this PR more straightforward to achieve.

@akien-mga
Copy link
Member

Superseded by #31237.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants