Browse Source

Revert follow-ups to #102313 before reverting that PR

This reverts the following commits:

- cd6e5ba9f48801d7c2c6708a7cec0ff200d2118a
- d36a3e5c06cda25b5e7d1212e8a7bc3f1724e169
- f2c6d16290354bd9fa6605583eb5fc49dff59421
- aae51963ef6dc4ca5b471990dce29c09abaa3adf
Rémi Verschelde 1 month ago
parent
commit
6af4ef019c
3 changed files with 28 additions and 35 deletions
  1. 12 28
      editor/editor_node.cpp
  2. 1 1
      editor/editor_node.h
  3. 15 6
      editor/plugins/editor_preview_plugins.cpp

+ 12 - 28
editor/editor_node.cpp

@@ -1998,7 +1998,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(), -1, false);
+		_save_scene(scene->get_scene_file_path());
 		save_editor_layout_delayed();
 		save_editor_layout_delayed();
 	}
 	}
 }
 }
@@ -2026,29 +2026,23 @@ static void _reset_animation_mixers(Node *p_node, List<Pair<AnimationMixer *, Re
 	}
 	}
 }
 }
 
 
-void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
+void EditorNode::_save_scene(String p_file, int idx) {
 	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);
 
 
-	if (show_progress) {
-		save_scene_progress = memnew(EditorProgress("save", TTR("Saving Scene"), 3));
-		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"));
-		if (show_progress) {
-			_close_save_scene_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"));
-		if (show_progress) {
-			_close_save_scene_progress();
-		}
+		_close_save_scene_progress();
 		return;
 		return;
 	}
 	}
 
 
@@ -2060,9 +2054,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
 	_reset_animation_mixers(scene, &anim_backups);
 	_reset_animation_mixers(scene, &anim_backups);
 	_save_editor_states(p_file, idx);
 	_save_editor_states(p_file, idx);
 
 
-	if (show_progress) {
-		save_scene_progress->step(TTR("Packing Scene"), 1);
-	}
+	save_scene_progress->step(TTR("Packing Scene"), 1);
 
 
 	Ref<PackedScene> sdata;
 	Ref<PackedScene> sdata;
 
 
@@ -2084,15 +2076,11 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
 
 
 	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"));
-		if (show_progress) {
-			_close_save_scene_progress();
-		}
+		_close_save_scene_progress();
 		return;
 		return;
 	}
 	}
 
 
-	if (show_progress) {
-		save_scene_progress->step(TTR("Saving scene"), 2);
-	}
+	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")) {
@@ -2106,9 +2094,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
 	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);
 
 
-	if (show_progress) {
-		save_scene_progress->step(TTR("Saving external resources"), 3);
-	}
+	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.
@@ -2134,9 +2120,7 @@ void EditorNode::_save_scene(String p_file, int idx, bool show_progress) {
 
 
 	scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE);
 	scene->propagate_notification(NOTIFICATION_EDITOR_POST_SAVE);
 	_update_unsaved_cache();
 	_update_unsaved_cache();
-	if (show_progress) {
-		_close_save_scene_progress();
-	}
+	_close_save_scene_progress();
 }
 }
 
 
 void EditorNode::save_all_scenes() {
 void EditorNode::save_all_scenes() {
@@ -2176,7 +2160,7 @@ void EditorNode::try_autosave() {
 		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()) { // Only autosave if there is a scene and if it has a path.
 		if (scene && !scene->get_scene_file_path().is_empty()) { // Only autosave if there is a scene and if it has a path.
-			_save_scene(scene->get_scene_file_path(), -1, false);
+			_save_scene(scene->get_scene_file_path());
 		}
 		}
 	}
 	}
 	_menu_option(SCENE_SAVE_ALL_SCENES);
 	_menu_option(SCENE_SAVE_ALL_SCENES);

+ 1 - 1
editor/editor_node.h

@@ -592,7 +592,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, bool show_progress = true);
+	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);
 	void _discard_changes(const String &p_str = String());
 	void _discard_changes(const String &p_str = String());

+ 15 - 6
editor/plugins/editor_preview_plugins.cpp

@@ -324,7 +324,7 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
 	aborted = false;
 	aborted = false;
 
 
 	Error load_error;
 	Error load_error;
-	Ref<PackedScene> pack = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE_DEEP, &load_error); // no more cache issues?
+	Ref<PackedScene> pack = ResourceLoader::load(p_path, "PackedScene", ResourceFormatLoader::CACHE_MODE_IGNORE, &load_error); // no more cache issues?
 	if (load_error != OK) {
 	if (load_error != OK) {
 		print_error(vformat("Failed to generate scene thumbnail for %s : Loaded with error code %d", p_path, int(load_error)));
 		print_error(vformat("Failed to generate scene thumbnail for %s : Loaded with error code %d", p_path, int(load_error)));
 		return Ref<Texture2D>();
 		return Ref<Texture2D>();
@@ -342,11 +342,6 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
 
 
 	Node *p_scene = pack->instantiate(); // The instantiated preview scene
 	Node *p_scene = pack->instantiate(); // The instantiated preview scene
 
 
-	if (!p_scene) {
-		print_error(vformat("Failed to generate scene thumbnail for %s : Failed to instantiate scene", p_path));
-		return Ref<Texture2D>();
-	}
-
 	// Prohibit Viewport class as root when generating thumbnails
 	// Prohibit Viewport class as root when generating thumbnails
 	if (Object::cast_to<Viewport>(p_scene)) {
 	if (Object::cast_to<Viewport>(p_scene)) {
 		p_scene->queue_free();
 		p_scene->queue_free();
@@ -588,6 +583,13 @@ Ref<Texture2D> EditorPackedScenePreviewPlugin::generate_from_path(const String &
 }
 }
 
 
 void EditorPackedScenePreviewPlugin::_setup_scene_3d(Node *p_node) const {
 void EditorPackedScenePreviewPlugin::_setup_scene_3d(Node *p_node) const {
+	// Do not account any SubViewport at preview scene, as it would not render correctly
+	if (Object::cast_to<SubViewport>(p_node) && p_node->get_parent()) {
+		p_node->get_parent()->remove_child(p_node);
+		callable_mp(p_node, &Node::queue_free).call_deferred();
+		return;
+	}
+
 	// Don't let window to popup
 	// Don't let window to popup
 	Window *window = Object::cast_to<Window>(p_node);
 	Window *window = Object::cast_to<Window>(p_node);
 	if (window) {
 	if (window) {
@@ -637,6 +639,13 @@ void EditorPackedScenePreviewPlugin::_setup_scene_3d(Node *p_node) const {
 }
 }
 
 
 void EditorPackedScenePreviewPlugin::_setup_scene_2d(Node *p_node) const {
 void EditorPackedScenePreviewPlugin::_setup_scene_2d(Node *p_node) const {
+	// Do not account any SubViewport at preview scene, as it would not render correctly
+	if (Object::cast_to<SubViewport>(p_node) && p_node->get_parent()) {
+		p_node->get_parent()->remove_child(p_node);
+		callable_mp(p_node, &Node::queue_free).call_deferred();
+		return;
+	}
+
 	// Don't let window to popup
 	// Don't let window to popup
 	Window *window = Object::cast_to<Window>(p_node);
 	Window *window = Object::cast_to<Window>(p_node);
 	if (window) {
 	if (window) {