Fix #145186: Allow opening non-existing blend from command line

The PR restores the old behavior (after the changes in #139128) so that
specifying a path to a non-existing blend file will load Blender with
default blend default and with that name assigned. Paths to non-blend
files will load blender but then give the new warning message.

Pull Request: https://projects.blender.org/blender/blender/pulls/145274
This commit is contained in:
Harley Acheson
2025-08-28 16:48:45 +02:00
committed by Harley Acheson
parent 20956c69fa
commit 9e0ef26686

View File

@@ -2675,18 +2675,18 @@ static bool handle_load_file(bContext *C, const char *filepath_arg, const bool l
if (load_empty_file == false) {
error_msg = error_msg_generic;
}
else if (BLI_exists(filepath) && BKE_blendfile_extension_check(filepath)) {
else if (!BKE_blendfile_extension_check(filepath)) {
/* Non-blend. Continue loading and give warning. */
G_MAIN->is_read_invalid = true;
return true;
}
else if (BLI_exists(filepath)) {
/* When a file is found but can't be loaded, handling it as a new file
* could cause it to be unintentionally overwritten (data loss).
* Further this is almost certainly not that a user would expect or want.
* If they do, they can delete the file beforehand. */
error_msg = error_msg_generic;
}
else {
/* Non-blend or non-existing. Continue loading and give warning. */
G_MAIN->is_read_invalid = true;
return true;
}
if (error_msg) {
fprintf(stderr, "Error: %s, exiting! %s\n", error_msg, filepath);