From 0b1fb22f6977a59bc69065bcb8f9e7a0ec708dc9 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 17 Apr 2023 13:31:08 +1000 Subject: [PATCH] Fix screenshot path defaulting to the root directory for unsaved files Using a "//" prefix resolves to the root directory which isn't a good default as it typically doesn't have write permissions. Only set the name and let the file selector pick a directory to use (matches how saving from the text editor works). --- source/blender/editors/screen/screendump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 9a1d4075db9..5d9cb4be166 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -167,12 +167,15 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *event) /* extension is added by 'screenshot_check' after */ char filepath[FILE_MAX]; - BLI_snprintf(filepath, FILE_MAX, "//%s", DATA_("screen")); const char *blendfile_path = BKE_main_blendfile_path_from_global(); if (blendfile_path[0] != '\0') { BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); BLI_path_extension_replace(filepath, sizeof(filepath), ""); /* strip '.blend' */ } + else { + /* As the file isn't saved, only set the name and let the file selector pick a directory. */ + STRNCPY(filepath, DATA_("screen")); + } RNA_string_set(op->ptr, "filepath", filepath); WM_event_add_fileselect(C, op);