Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@stuvel.eu>2015-11-25 14:47:54 +0300
committerSybren A. Stüvel <sybren@stuvel.eu>2015-11-25 15:59:21 +0300
commit6894fe3b7a200c4eae8ad980c3dcafe54e52393f (patch)
treecb58f46fed038b35e297b324110122eb3888083f /source/creator
parente796581655ed9a36c263a20e7ed97856fc0f1070 (diff)
Accept non-existing files from the CLI
When a user tries to load a non-existing blend file from the CLI, the path is set and Blender acts as if it is loaded. This allows the user to create a new file by typing 'blender filename.blend' and then saving. This behaviour is common in other tooling, such as vim and Mypaint. Blender's current behaviour (print an error message and open the default scene) doesn't make much sense. It ignores the filename passed on the CLI, whereas with this patch that filename is actually remembered, and used when saving. Reviewers: campbellbarton, sergey, mont29
Diffstat (limited to 'source/creator')
-rw-r--r--source/creator/creator.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/creator/creator.c b/source/creator/creator.c
index c6203b6fd40..f7dd0aaf736 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -1505,7 +1505,7 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
}
}
else {
- /* failed to load file, stop processing arguments */
+ /* failed to load file, stop processing arguments if running in background mode */
if (G.background) {
/* Set is_break if running in the background mode so
* blender will return non-zero exit code which then
@@ -1513,8 +1513,14 @@ static int load_file(int UNUSED(argc), const char **argv, void *data)
* good or bad things are.
*/
G.is_break = true;
+ return -1;
}
- return -1;
+
+ /* Just pretend a file was loaded, so the user can press Save and it'll save at the filename from the CLI. */
+ BLI_strncpy(G.main->name, filename, FILE_MAX);
+ G.relbase_valid = true;
+ G.save_over = true;
+ printf("... opened default scene instead; saving will write to %s\n", filename);
}
G.file_loaded = 1;