Fixes godot crash or give unclear message when exporting with invalid args

(cherry picked from commit 1d09970404)
This commit is contained in:
jsjtxietian 2024-08-01 13:00:05 +08:00 committed by Rémi Verschelde
parent c4525f24e3
commit fb1758ce23
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 6 additions and 1 deletions

View File

@ -3371,13 +3371,16 @@ int Main::start() {
gdscript_docs_path = E->next()->get(); gdscript_docs_path = E->next()->get();
#endif #endif
} else if (E->get() == "--export-release") { } else if (E->get() == "--export-release") {
ERR_FAIL_COND_V_MSG(!editor && !found_project, EXIT_FAILURE, "Please provide a valid project path when exporting, aborting.");
editor = true; //needs editor editor = true; //needs editor
_export_preset = E->next()->get(); _export_preset = E->next()->get();
} else if (E->get() == "--export-debug") { } else if (E->get() == "--export-debug") {
ERR_FAIL_COND_V_MSG(!editor && !found_project, EXIT_FAILURE, "Please provide a valid project path when exporting, aborting.");
editor = true; //needs editor editor = true; //needs editor
_export_preset = E->next()->get(); _export_preset = E->next()->get();
export_debug = true; export_debug = true;
} else if (E->get() == "--export-pack") { } else if (E->get() == "--export-pack") {
ERR_FAIL_COND_V_MSG(!editor && !found_project, EXIT_FAILURE, "Please provide a valid project path when exporting, aborting.");
editor = true; editor = true;
_export_preset = E->next()->get(); _export_preset = E->next()->get();
export_pack_only = true; export_pack_only = true;
@ -3389,6 +3392,8 @@ int Main::start() {
if (parsed_pair) { if (parsed_pair) {
E = E->next(); E = E->next();
} }
} else if (E->get().begins_with("--export-")) {
ERR_FAIL_V_MSG(EXIT_FAILURE, "Missing export preset name, aborting.");
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
// Handle case where no path is given to --doctool. // Handle case where no path is given to --doctool.
@ -4227,7 +4232,7 @@ bool Main::iteration() {
} }
#ifdef TOOLS_ENABLED #ifdef TOOLS_ENABLED
if (wait_for_import && EditorFileSystem::get_singleton()->doing_first_scan()) { if (wait_for_import && EditorFileSystem::get_singleton() && EditorFileSystem::get_singleton()->doing_first_scan()) {
exit = false; exit = false;
} }
#endif #endif