Fixes misleading error message when trying to export

This patch fixes the misleading error message when users
try to "export all" into an invalid destination path.

Closes #26539
This commit is contained in:
Ricardo Lüders 2019-03-05 08:52:45 +01:00
parent 9dd9737cb4
commit 3fdbdd8380
7 changed files with 29 additions and 1 deletions

View file

@ -1456,6 +1456,10 @@ List<String> EditorExportPlatformPC::get_binary_extensions(const Ref<EditorExpor
Error EditorExportPlatformPC::export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags) {
ExportNotifier notifier(*this, p_preset, p_debug, p_path, p_flags);
if (!FileAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
String custom_debug = p_preset->get("custom_template/debug");
String custom_release = p_preset->get("custom_template/release");

View file

@ -1012,7 +1012,11 @@ void ProjectExportDialog::_export_all(bool p_debug) {
Error err = platform->export_project(preset, p_debug, preset->get_export_path(), 0);
if (err != OK) {
if (err == ERR_FILE_BAD_PATH) {
error_dialog->set_text(TTR("The given export path doesn't exist:") + "\n" + preset->get_export_path().get_base_dir());
} else {
error_dialog->set_text(TTR("Export templates for this platform are missing/corrupted:") + " " + platform->get_name());
}
error_dialog->show();
error_dialog->popup_centered_minsize(Size2(300, 80));
ERR_PRINT("Failed to export project");

View file

@ -1489,6 +1489,10 @@ public:
}
}
if (!FileAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

View file

@ -840,6 +840,10 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
}
}
if (!FileAccess::exists(dest_dir)) {
return ERR_FILE_BAD_PATH;
}
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (da) {
String current_dir = da->get_current_dir();

View file

@ -211,6 +211,10 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
}
if (!FileAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
if (template_path != String() && !FileAccess::exists(template_path)) {
EditorNode::get_singleton()->show_warning(TTR("Template file not found:") + "\n" + template_path);
return ERR_FILE_NOT_FOUND;

View file

@ -425,6 +425,10 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p
}
}
if (!FileAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
FileAccess *src_f = NULL;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

View file

@ -1265,6 +1265,10 @@ public:
}
}
if (!FileAccess::exists(p_path.get_base_dir())) {
return ERR_FILE_BAD_PATH;
}
Error err = OK;
FileAccess *fa_pack = FileAccess::open(p_path, FileAccess::WRITE, &err);