Skip to content

Commit

Permalink
Add some checks to avoid disaster when making a node the scene root. F…
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz authored and root committed Jan 22, 2019
1 parent 2be0ef5 commit f9a072d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions editor/scene_tree_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,20 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
if (node == root)
return;

//check that from node to root, all owners are right

if (node->get_owner() != root) {
accept->set_text(TTR("Node must belong to the edited scene to become root."));
accept->popup_centered_minsize();
return;
}

if (node->get_filename() != String()) {
accept->set_text(TTR("Instantiated scenes can't become root"));
accept->popup_centered_minsize();
return;
}

editor_data->get_undo_redo().create_action("Make node as Root");
editor_data->get_undo_redo().add_do_method(node->get_parent(), "remove_child", node);
editor_data->get_undo_redo().add_do_method(root->get_parent(), "remove_child", root);
Expand Down
1 change: 1 addition & 0 deletions scene/2d/canvas_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ void CanvasItemMaterial::init_shaders() {
void CanvasItemMaterial::finish_shaders() {

memdelete(dirty_materials);
memdelete(shader_names);
dirty_materials = NULL;

#ifndef NO_THREADS
Expand Down

0 comments on commit f9a072d

Please sign in to comment.