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:
authorCampbell Barton <campbell@blender.org>2022-10-05 07:30:44 +0300
committerCampbell Barton <campbell@blender.org>2022-10-05 07:34:02 +0300
commit79774aa68ce3f33547b0daf928874a13218d2aee (patch)
tree1017e654eee0078919330e0a08005d69f0e9c3a4
parent5dc798f2e4886906336be8d3095a3ff8a196c173 (diff)
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.
-rw-r--r--source/blender/blenkernel/intern/blendfile.c10
1 files 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);
}