summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-01-11 15:47:07 +0100
committerGitHub <noreply@github.com>2018-01-11 15:47:07 +0100
commit920715b97db4f3d63dfdc0f38141ce842a9bad63 (patch)
tree969d5a91511826da751f7d0160cf008986c5867b
parent9135e6151270118bfab5d40889ac3b1caeba4ce7 (diff)
parent1bdde70dd083f7a967681f34edca34f2dc3668d8 (diff)
Merge pull request #15571 from RandomShaper/fix-crash-save-branch
Fix crash on save-branch-as-scene
-rw-r--r--editor/scene_tree_dock.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index d8d44a635a..b1b65952f4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -237,13 +237,20 @@ void SceneTreeDock::_replace_with_branch_scene(const String &p_file, Node *base)
Node *parent = base->get_parent();
int pos = base->get_index();
- memdelete(base);
+ parent->remove_child(base);
parent->add_child(instanced_scene);
parent->move_child(instanced_scene, pos);
instanced_scene->set_owner(edited_scene);
editor_selection->clear();
editor_selection->add_node(instanced_scene);
scene_tree->set_selected(instanced_scene);
+
+ // Delete the node as late as possible because before another one is selected
+ // an editor plugin could be referencing it to do something with it before
+ // switching to another (or to none); and since some steps of changing the
+ // editor state are deferred, the safest thing is to do this is as the last
+ // step of this function and also by enqueing instead of memdelete()-ing it here
+ base->queue_delete();
}
bool SceneTreeDock::_cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node) {