You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Added test to avoid saving cyclic scene instancing, fixes #9686
This commit is contained in:
@@ -999,6 +999,22 @@ void EditorNode::_save_scene_with_preview(String p_file, int p_idx) {
|
|||||||
EditorResourcePreview::get_singleton()->check_for_invalidation(p_file);
|
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) {
|
void EditorNode::_save_scene(String p_file, int idx) {
|
||||||
|
|
||||||
Node *scene = editor_data.get_edited_scene_root(idx);
|
Node *scene = editor_data.get_edited_scene_root(idx);
|
||||||
@@ -1009,6 +1025,11 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||||||
return;
|
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();
|
editor_data.apply_changes_in_editors();
|
||||||
_save_default_environment();
|
_save_default_environment();
|
||||||
|
|
||||||
|
|||||||
@@ -445,6 +445,7 @@ private:
|
|||||||
void _show_messages();
|
void _show_messages();
|
||||||
void _vp_resized();
|
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_scene(String p_file, int idx = -1);
|
||||||
void _save_all_scenes();
|
void _save_all_scenes();
|
||||||
int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
|
int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user