Fix crash when save_on_focus_loss is enabled
This commit is contained in:
parent
1bbfe637c6
commit
aae51963ef
@ -1957,7 +1957,7 @@ void EditorNode::_save_scene_silently() {
|
|||||||
// when Save on Focus Loss kicks in.
|
// when Save on Focus Loss kicks in.
|
||||||
Node *scene = editor_data.get_edited_scene_root();
|
Node *scene = editor_data.get_edited_scene_root();
|
||||||
if (scene && !scene->get_scene_file_path().is_empty() && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
|
if (scene && !scene->get_scene_file_path().is_empty() && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
|
||||||
_save_scene(scene->get_scene_file_path());
|
_save_scene(scene->get_scene_file_path(), -1, false);
|
||||||
save_editor_layout_delayed();
|
save_editor_layout_delayed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1985,23 +1985,29 @@ static void _reset_animation_mixers(Node *p_node, List<Pair<AnimationMixer *, Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::_save_scene(String p_file, int idx) {
|
void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
|
||||||
ERR_FAIL_COND_MSG(!saving_scene.is_empty() && saving_scene == p_file, "Scene saved while already being saved!");
|
ERR_FAIL_COND_MSG(!saving_scene.is_empty() && saving_scene == p_file, "Scene saved while already being saved!");
|
||||||
|
|
||||||
Node *scene = editor_data.get_edited_scene_root(idx);
|
Node *scene = editor_data.get_edited_scene_root(idx);
|
||||||
|
|
||||||
save_scene_progress = memnew(EditorProgress("save", TTR("Saving Scene"), 3));
|
if (show_progress) {
|
||||||
save_scene_progress->step(TTR("Analyzing"), 0);
|
save_scene_progress = memnew(EditorProgress("save", TTR("Saving Scene"), 3));
|
||||||
|
save_scene_progress->step(TTR("Analyzing"), 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!scene) {
|
if (!scene) {
|
||||||
show_accept(TTR("This operation can't be done without a tree root."), TTR("OK"));
|
show_accept(TTR("This operation can't be done without a tree root."), TTR("OK"));
|
||||||
_close_save_scene_progress();
|
if (show_progress) {
|
||||||
|
_close_save_scene_progress();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scene->get_scene_file_path().is_empty() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) {
|
if (!scene->get_scene_file_path().is_empty() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) {
|
||||||
show_accept(TTR("This scene can't be saved because there is a cyclic instance inclusion.\nPlease resolve it and then attempt to save again."), TTR("OK"));
|
show_accept(TTR("This scene can't be saved because there is a cyclic instance inclusion.\nPlease resolve it and then attempt to save again."), TTR("OK"));
|
||||||
_close_save_scene_progress();
|
if (show_progress) {
|
||||||
|
_close_save_scene_progress();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2013,7 +2019,9 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||||||
_reset_animation_mixers(scene, &anim_backups);
|
_reset_animation_mixers(scene, &anim_backups);
|
||||||
_save_editor_states(p_file, idx);
|
_save_editor_states(p_file, idx);
|
||||||
|
|
||||||
save_scene_progress->step(TTR("Packing Scene"), 1);
|
if (show_progress) {
|
||||||
|
save_scene_progress->step(TTR("Packing Scene"), 1);
|
||||||
|
}
|
||||||
|
|
||||||
Ref<PackedScene> sdata;
|
Ref<PackedScene> sdata;
|
||||||
|
|
||||||
@ -2035,11 +2043,15 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||||||
|
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK"));
|
show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK"));
|
||||||
_close_save_scene_progress();
|
if (show_progress) {
|
||||||
|
_close_save_scene_progress();
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
save_scene_progress->step(TTR("Saving scene"), 2);
|
if (show_progress) {
|
||||||
|
save_scene_progress->step(TTR("Saving scene"), 2);
|
||||||
|
}
|
||||||
|
|
||||||
int flg = 0;
|
int flg = 0;
|
||||||
if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
|
if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
|
||||||
@ -2053,7 +2065,9 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||||||
emit_signal(SNAME("scene_saved"), p_file);
|
emit_signal(SNAME("scene_saved"), p_file);
|
||||||
editor_data.notify_scene_saved(p_file);
|
editor_data.notify_scene_saved(p_file);
|
||||||
|
|
||||||
save_scene_progress->step(TTR("Saving external resources"), 3);
|
if (show_progress) {
|
||||||
|
save_scene_progress->step(TTR("Saving external resources"), 3);
|
||||||
|
}
|
||||||
|
|
||||||
_save_external_resources();
|
_save_external_resources();
|
||||||
saving_scene = p_file; // Some editors may save scenes of built-in resources as external data, so avoid saving this scene again.
|
saving_scene = p_file; // Some editors may save scenes of built-in resources as external data, so avoid saving this scene again.
|
||||||
@ -2079,7 +2093,9 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
|||||||
|
|
||||||
scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE);
|
scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE);
|
||||||
_update_unsaved_cache();
|
_update_unsaved_cache();
|
||||||
_close_save_scene_progress();
|
if (show_progress) {
|
||||||
|
_close_save_scene_progress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorNode::save_all_scenes() {
|
void EditorNode::save_all_scenes() {
|
||||||
|
@ -587,7 +587,7 @@ private:
|
|||||||
void _set_current_scene(int p_idx);
|
void _set_current_scene(int p_idx);
|
||||||
void _set_current_scene_nocheck(int p_idx);
|
void _set_current_scene_nocheck(int p_idx);
|
||||||
bool _validate_scene_recursive(const String &p_filename, Node *p_node);
|
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, bool show_progress = true);
|
||||||
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);
|
||||||
void _discard_changes(const String &p_str = String());
|
void _discard_changes(const String &p_str = String());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user