Skip to content

Commit 6af4ef0

Browse files
committed
Revert follow-ups to #102313 before reverting that PR
This reverts the following commits: - cd6e5ba - d36a3e5 - f2c6d16 - aae5196
1 parent 48f361a commit 6af4ef0

File tree

3 files changed

+28
-35
lines changed

3 files changed

+28
-35
lines changed

editor/editor_node.cpp

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,7 +1998,7 @@ void EditorNode::_save_scene_silently() {
19981998
// when Save on Focus Loss kicks in.
19991999
Node *scene = editor_data.get_edited_scene_root();
20002000
if (scene && !scene->get_scene_file_path().is_empty() && DirAccess::exists(scene->get_scene_file_path().get_base_dir())) {
2001-
_save_scene(scene->get_scene_file_path(), -1, false);
2001+
_save_scene(scene->get_scene_file_path());
20022002
save_editor_layout_delayed();
20032003
}
20042004
}
@@ -2026,29 +2026,23 @@ static void _reset_animation_mixers(Node *p_node, List<Pair<AnimationMixer *, Re
20262026
}
20272027
}
20282028

2029-
void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
2029+
void EditorNode::_save_scene(String p_file, int idx) {
20302030
ERR_FAIL_COND_MSG(!saving_scene.is_empty() && saving_scene == p_file, "Scene saved while already being saved!");
20312031

20322032
Node *scene = editor_data.get_edited_scene_root(idx);
20332033

2034-
if (show_progress) {
2035-
save_scene_progress = memnew(EditorProgress("save", TTR("Saving Scene"), 3));
2036-
save_scene_progress->step(TTR("Analyzing"), 0);
2037-
}
2034+
save_scene_progress = memnew(EditorProgress("save", TTR("Saving Scene"), 3));
2035+
save_scene_progress->step(TTR("Analyzing"), 0);
20382036

20392037
if (!scene) {
20402038
show_accept(TTR("This operation can't be done without a tree root."), TTR("OK"));
2041-
if (show_progress) {
2042-
_close_save_scene_progress();
2043-
}
2039+
_close_save_scene_progress();
20442040
return;
20452041
}
20462042

20472043
if (!scene->get_scene_file_path().is_empty() && _validate_scene_recursive(scene->get_scene_file_path(), scene)) {
20482044
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"));
2049-
if (show_progress) {
2050-
_close_save_scene_progress();
2051-
}
2045+
_close_save_scene_progress();
20522046
return;
20532047
}
20542048

@@ -2060,9 +2054,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
20602054
_reset_animation_mixers(scene, &anim_backups);
20612055
_save_editor_states(p_file, idx);
20622056

2063-
if (show_progress) {
2064-
save_scene_progress->step(TTR("Packing Scene"), 1);
2065-
}
2057+
save_scene_progress->step(TTR("Packing Scene"), 1);
20662058

20672059
Ref<PackedScene> sdata;
20682060

@@ -2084,15 +2076,11 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
20842076

20852077
if (err != OK) {
20862078
show_accept(TTR("Couldn't save scene. Likely dependencies (instances or inheritance) couldn't be satisfied."), TTR("OK"));
2087-
if (show_progress) {
2088-
_close_save_scene_progress();
2089-
}
2079+
_close_save_scene_progress();
20902080
return;
20912081
}
20922082

2093-
if (show_progress) {
2094-
save_scene_progress->step(TTR("Saving scene"), 2);
2095-
}
2083+
save_scene_progress->step(TTR("Saving scene"), 2);
20962084

20972085
int flg = 0;
20982086
if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
@@ -2106,9 +2094,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
21062094
emit_signal(SNAME("scene_saved"), p_file);
21072095
editor_data.notify_scene_saved(p_file);
21082096

2109-
if (show_progress) {
2110-
save_scene_progress->step(TTR("Saving external resources"), 3);
2111-
}
2097+
save_scene_progress->step(TTR("Saving external resources"), 3);
21122098

21132099
_save_external_resources();
21142100
saving_scene = p_file; // Some editors may save scenes of built-in resources as external data, so avoid saving this scene again.
@@ -2134,9 +2120,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
21342120

21352121
scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE);
21362122
_update_unsaved_cache();
2137-
if (show_progress) {
2138-
_close_save_scene_progress();
2139-
}
2123+
_close_save_scene_progress();
21402124
}
21412125

21422126
void EditorNode::save_all_scenes() {
@@ -2176,7 +2160,7 @@ void EditorNode::try_autosave() {
21762160
Node *scene = editor_data.get_edited_scene_root();
21772161

21782162
if (scene && !scene->get_scene_file_path().is_empty()) { // Only autosave if there is a scene and if it has a path.
2179-
_save_scene(scene->get_scene_file_path(), -1, false);
2163+
_save_scene(scene->get_scene_file_path());
21802164
}
21812165
}
21822166
_menu_option(SCENE_SAVE_ALL_SCENES);

editor/editor_node.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class EditorNode : public Node {
592592
void _set_current_scene(int p_idx);
593593
void _set_current_scene_nocheck(int p_idx);
594594
bool _validate_scene_recursive(const String &p_filename, Node *p_node);
595-
void _save_scene(String p_file, int idx = -1, bool show_progress = true);
595+
void _save_scene(String p_file, int idx = -1);
596596
void _save_all_scenes();
597597
int _next_unsaved_scene(bool p_valid_filename, int p_start = 0);
598598
void _discard_changes(const String &p_str = String());

editor/plugins/editor_preview_plugins.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
324324
aborted = false;
325325

326326
Error load_error;
327-
Ref<PackedScene> pack = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP, &load_error); // no more cache issues?
327+
Ref<PackedScene> pack = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE, &load_error); // no more cache issues?
328328
if (load_error != OK) {
329329
print_error(vformat("Failed to generate scene thumbnail for %s : Loaded with error code %d", p_path, int(load_error)));
330330
return Ref<Texture2D>();
@@ -342,11 +342,6 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
342342

343343
Node *p_scene = pack->instantiate(); // The instantiated preview scene
344344

345-
if (!p_scene) {
346-
print_error(vformat("Failed to generate scene thumbnail for %s : Failed to instantiate scene", p_path));
347-
return Ref<Texture2D>();
348-
}
349-
350345
// Prohibit Viewport class as root when generating thumbnails
351346
if (Object::cast_to<Viewport>(p_scene)) {
352347
p_scene->queue_free();
@@ -588,6 +583,13 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
588583
}
589584

590585
void EditorPackedScenePreviewPlugin::_setup_scene_3d(Node *p_node) const {
586+
// Do not account any SubViewport at preview scene, as it would not render correctly
587+
if (Object::cast_to<SubViewport>(p_node) && p_node->get_parent()) {
588+
p_node->get_parent()->remove_child(p_node);
589+
callable_mp(p_node, &Node::queue_free).call_deferred();
590+
return;
591+
}
592+
591593
// Don't let window to popup
592594
Window *window = Object::cast_to<Window>(p_node);
593595
if (window) {
@@ -637,6 +639,13 @@ void EditorPackedScenePreviewPlugin::_setup_scene_3d(Node *p_node) const {
637639
}
638640

639641
void EditorPackedScenePreviewPlugin::_setup_scene_2d(Node *p_node) const {
642+
// Do not account any SubViewport at preview scene, as it would not render correctly
643+
if (Object::cast_to<SubViewport>(p_node) && p_node->get_parent()) {
644+
p_node->get_parent()->remove_child(p_node);
645+
callable_mp(p_node, &Node::queue_free).call_deferred();
646+
return;
647+
}
648+
640649
// Don't let window to popup
641650
Window *window = Object::cast_to<Window>(p_node);
642651
if (window) {

0 commit comments

Comments
 (0)