Added test to avoid saving cyclic scene instancing, fixes #9686
This commit is contained in:
parent
f2ae14f309
commit
616b91b498
|
@ -999,6 +999,22 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
|
|||
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
|
||||
}
|
||||
|
||||
bool EditorNode::_validate_scene_recursive(const String &p_filename, Node *p_node) {
|
||||
|
||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||
Node *child = p_node->get_child(i);
|
||||
if (child->get_filename() == p_filename) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_validate_scene_recursive(p_filename, child)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditorNode::_save_scene(String p_file, int idx) {
|
||||
|
||||
Node *scene = editor_data.get_edited_scene_root(idx);
|
||||
|
@ -1009,6 +1025,11 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (scene->get_filename() != String() && _validate_scene_recursive(scene->get_filename(), scene)) {
|
||||
show_accept(TTR("This scene can't be saved because there is a cyclic instancing inclusion.\nPlease resolve it and then attempt to save again."), TTR("OK"));
|
||||
return;
|
||||
}
|
||||
|
||||
editor_data.apply_changes_in_editors();
|
||||
_save_default_environment();
|
||||
|
||||
|
@ -1452,7 +1473,7 @@ void EditorNode::_edit_current() {
|
|||
bool is_node = current_obj->is_class("Node");
|
||||
|
||||
String editable_warning; //none by default
|
||||
|
||||
|
||||
if (is_resource) {
|
||||
|
||||
Resource *current_res = Object::cast_to<Resource>(current_obj);
|
||||
|
|
|
@ -445,6 +445,7 @@ private:
|
|||
void _show_messages();
|
||||
void _vp_resized();
|
||||
|
||||
bool _validate_scene_recursive(const String &p_filename, Node *p_node);
|
||||
void _save_scene(String p_file, int idx = -1);
|
||||
void _save_all_scenes();
|
||||
int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
|
||||
|
|
Loading…
Reference in New Issue