From 79774aa68ce3f33547b0daf928874a13218d2aee Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 5 Oct 2022 15:30:44 +1100 Subject: App Template: quiet warning when existing preferences don't exist Suppress warning when saving app-template preferences. Check if the preferences exist before attempting to read them, while harmless it looked as if something went wrong. --- source/blender/blenkernel/intern/blendfile.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index f5b385b1682..4601fc1fc3a 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -16,6 +16,7 @@ #include "DNA_screen_types.h" #include "DNA_workspace_types.h" +#include "BLI_fileops.h" #include "BLI_listbase.h" #include "BLI_path_util.h" #include "BLI_string.h" @@ -711,8 +712,13 @@ bool BKE_blendfile_userdef_write(const char *filepath, ReportList *reports) bool BKE_blendfile_userdef_write_app_template(const char *filepath, ReportList *reports) { - /* if it fails, overwrite is OK. */ - UserDef *userdef_default = BKE_blendfile_userdef_read(filepath, NULL); + /* Checking that `filepath` exists is not essential, it just avoids printing a warning that + * the file can't be found. In this case it's not an error - as the file is used if it exists, + * falling back to the defaults. + * If the preferences exists but file reading fails - the file can be assumed corrupt + * so overwriting the file is OK. */ + UserDef *userdef_default = BLI_exists(filepath) ? BKE_blendfile_userdef_read(filepath, NULL) : + NULL; if (userdef_default == NULL) { return BKE_blendfile_userdef_write(filepath, reports); } -- cgit v1.2.3